【发布时间】:2017-04-06 08:59:40
【问题描述】:
我在我的项目中使用 ConstraintLayout 发现了一个非常奇怪的错误。事实上,这个问题只存在于 android 6。
我正在使用以下 XML 来显示用于不同登录可能性的按钮列表:
<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>
我的问题与 LinearLayout 中的 app:layout_constraintBottom_toBottomOf="parent" 有关。在 Android 6 上,LinearLayout 被裁剪而不是粘在底部。它在 android 7 甚至 android 4.4.2 上都能正常工作。在那之后,我尝试删除我的 LinearLayout 以仅使用 ConstraintLayout,但我仍然遇到同样的问题。
我做错了吗?还是 ConstraintLayout 库的问题?
谢谢!
【问题讨论】:
标签: android android-layout android-constraintlayout