I found a very strange bug using ConstraintLayout in my project. Indeed, this issue is only with android 6.
I'm using the following XML to display a list of buttons for different login possibilities :
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.fagets.rainbowsixapp.login.LoginStepOneFragment">
<LinearLayout
android:id="@+id/linearLayout_login_form"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
android:layout_marginStart="65dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="65dp"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="18dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="65dp"
android:layout_marginRight="65dp">
<com.facebook.login.widget.LoginButton
xmlns:facebook="http://schemas.android.com/apk/res-auto"
android:id="@+id/login_button_facebook"
style="@style/LoginButton"
android:paddingTop="15dp"
android:paddingBottom="15dp"
facebook:com_facebook_login_text="@string/login_connect_facebook"/>
<Button
android:id="@+id/login_button_google"
style="@style/LoginButton"
android:textColor="@color/login_button_google_text"
android:background="@drawable/login_button_shape_google"
android:text="@string/login_connect_google"/>
<Button
android:id="@+id/login_button_anonymous"
style="@style/LoginButton"
android:background="@drawable/login_button_shape_anonymous"
android:text="@string/login_connect_anonymous"/>
<Button
android:id="@+id/login_button_about"
style="@style/LoginButton"
android:background="@android:color/transparent"
android:text="@string/login_connect_about"
android:textColor="@color/login_button_google_text"/>
</LinearLayout>
My issue concern the app:layout_constraintBottom_toBottomOf="parent"
in the LinearLayout. On Android 6 the LinearLayout is cropped instead of being stick to the bottom. It's correctly working on android 7, and even on android 4.4.2. Just after that, I tried to remove my LinearLayout to only use the ConstraintLayout, but I still have the same issue.
Here is a screenshot on Android 7 :
And here the issue with Android 6 :
Am I doing something wrong ? Or is it an issue with ConstraintLayout library ?
Thanks !
You don't need that additional LinearLayout when you are working with the constranintLayout
XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="16dp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="1.0"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/button1" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="1.0"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/button2" />
</android.support.constraint.ConstraintLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.