如果我使用最新的材料库版本com.google.android.material:material:1.2.0-alpha02 ..>,我在TextInputEditText和他的提示消息上会遇到一些麻烦。我设置了5行scrollable textInputEditText,我想显示提示消息,使其与该文本输入的上边距对齐。在布局编辑器上显示在正确的位置,但是当我运行应用程序时,该位置在垂直居中。为什么?
相反,com.google.android.material:material:1.1.0-beta02
我没有遇到此问题这是我的布局:
<?xml version="1.0" encoding="utf-8"?> <ScrollView android:id="@+id/sendMailContainer" 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="wrap_content"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/popupTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="20dp" android:layout_marginTop="20dp" android:text="@string/sendBusinessCard" android:textColor="@android:color/black" android:textSize="22sp" /> <TextView android:id="@+id/subTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/sendBusinessCard" android:textColor="@android:color/black" android:textSize="18sp" android:layout_below="@+id/popupTitle" android:layout_marginEnd="40dp" android:layout_marginStart="40dp" android:layout_marginTop="20dp"/> <com.google.android.material.textfield.TextInputLayout android:id="@+id/noteMessageContainer" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/subTitle" android:layout_marginEnd="40dp" android:layout_marginStart="40dp" android:layout_marginTop="10dp"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/noteMessage" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/emailText" android:inputType="text|textMultiLine|textCapSentences" android:textColor="@android:color/black" android:textColorHint="@color/gray9B" android:textSize="16sp" android:isScrollContainer="true" android:scrollbars="vertical" android:textIsSelectable="true" android:minLines="5" android:maxLines="5" android:gravity="top"/> </com.google.android.material.textfield.TextInputLayout> <Button android:id="@+id/notePopupLeftButton" android:layout_width="180dp" android:layout_height="35dp" android:layout_alignParentStart="true" android:layout_below="@+id/noteMessageContainer" android:layout_marginBottom="20dp" android:layout_marginStart="20dp" android:layout_marginTop="40dp" android:background="#FF515151" android:text="@string/Cancel" android:textAllCaps="true" android:textColor="@android:color/white" android:textSize="16sp" android:textStyle="bold" /> <Button android:id="@+id/notePopupRightButton" android:layout_width="180dp" android:layout_height="35dp" android:layout_alignParentEnd="true" android:layout_below="@+id/noteMessageContainer" android:layout_marginBottom="20dp" android:layout_marginEnd="20dp" android:layout_marginTop="40dp" android:background="#FF515151" android:text="@string/Send" android:textAllCaps="true" android:textColor="@android:color/white" android:textSize="16sp" android:textStyle="bold" /> </RelativeLayout> </ScrollView>
这是两个屏幕截图,其中一个布局编辑器的提示位置正确,另一个是应用屏幕截图:
如果我使用最新的材料库版本com.google.android.material:material:1.2.0-alpha02,我在使用TextInputEditText及其提示消息时会遇到一些麻烦。我设置了5行可滚动显示...
将android:gravity =“ top | start”
您可以使用