Skip to content
Advertisement

ImageView layout BUG in the androidx.constraintlayout:constraintlayout:2.1.0

I’m using Android Studio 2020.3.1 patch 3 and the ConstraintLayout for displaying two rows UI.

Here is the expected UI latyout:

JavaScript

But the second_row_image_view is not at the expected position when using the “test.xml”, it is floating on the top of the first_row_edit_text.

Here is the build.gradle settings:

JavaScript

Here is the test layout: test.xml

JavaScript

But If I change the ImageView (second_row_image_view) to EditText with the same name, the ConstraintLayout can display the EditText at the right place.

JavaScript

Is it a BUG or something else?

Thanks.

For testing:

You can copy the test.xml to the res/layout, open the test.xml in the “Code” view, and then click on the “second_row_image_view”, finally, switch to the “Design” view, you can also find out that the second_row_image_view is floating on the top of the first_row_edit_text.

Advertisement

Answer

It is because of app:layout_constraintBaseline_toBaselineOf. Baseline is a property of text based views. ImageViews don’t have a baseline while EditTexts do

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement