我不想限制行数,我想限制new GridView.count(
shrinkWrap: true,
的最大高度,这样,如果它太长,它将变为垂直滚动。
我很满意代码解决方案。
当前TextInputLayout
属性对maxHeight
或TextInputLayout
均无效。
这是我的布局
EditText
我将其包含在约束布局中
<com.google.android.material.textfield.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="0dp"
android:layout_height="0dp"
android:hint="@string/address"
android:paddingTop="@dimen/margin_8"
android:paddingBottom="@dimen/margin_8">
<com.mamamia.mamamiarestaurant.ui.MultiLineTextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:imeOptions="actionNext"
android:inputType="text|textPostalAddress|textMultiLine"
android:maxLength="@integer/address_max_length" />
</com.google.android.material.textfield.TextInputLayout>
<include
android:id="@+id/text_input_layout_address"
layout="@layout/view_text_input_layout_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
app:layout_constraintHeight_max="200dp" />
无效。但是layout_constraintHeight_max
如果设置为true,将使布局固定高度(不是layout_constrainedHeight
指定的高度,而是固定的默认编辑文本高度)
答案 0 :(得分:0)
layout_constraintHeight_max
在视图没有顶部或底部约束的情况下不起作用,因此您可以将android:maxHeight
放在InputEditText
上,或调整TextInputLayout
上的约束:
<include
layout="@layout/view_text_input_layout_address"
android:id="@+id/text_input_layout_address"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="200dp" />
如果父母的身高为app:layout_constraintHeight_default="wrap"
,您可能只需要match_parent
。