android / views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.
Apache License 2.0
5.04k stars 3.01k forks source link

ConstraintLayout layout_constraintBottom_toBottomOf attribute not working properly on some mobile phones #33

Closed haianhsing closed 4 years ago

haianhsing commented 4 years ago

Describe the bug

While I add a wrap_content view in ConstraintLayout and set app:layout_constraintBottom_toBottomOf="parent", only adding android:layout_marginBottom="appropriate values", it can see at screen. Maybe onLayout function has some problem.

To Reproduce

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <TextView
            android:gravity="center"
            android:text="text"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>

</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <TextView
            android:gravity="center"
            android:text="text"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            android:layout_width="0dp"
            android:layout_marginBottom="48dp"
            android:layout_height="wrap_content"/>

</androidx.constraintlayout.widget.ConstraintLayout>

without margin with margin

Expected behavior

The view without margin also normal display

Known workaround

set android:layout_height="value" or do not use ConstraintLayout

Environment:

Hornor20, sansumg s9

haianhsing commented 4 years ago

After testing, CL 2.0 beta 3 has been fixed