Cru*_*ces 6 android android-textinputlayout
我有一个使用大量 textinputlayouts 的应用程序,因为我喜欢它们创建的样式
在一个屏幕上,我正在显示一个对象的信息,我希望它也看起来像用户使用 textinputedittexts 输入的数据,上面的小标题和下面的数据
现在我有一个 textinputlayout,下面有一个禁用的 textinputedittext
有没有办法让 textinputlayout 下的 textview 以相同的样式显示?
提前感谢您提供的任何帮助
编辑:
作为旁注,这是我目前用来完全禁用编辑文本的内容
<android.support.design.widget.TextInputLayout
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/name"
tools:text="This is where the name goes"
android:inputType="none"
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false" />
Run Code Online (Sandbox Code Playgroud)
我试图避免的不是在我尝试创建的每个视图中使用 clickable 和 inputtype 等,而是使用单个视图
所以除了创建一个以各种方式启动 unclickabke 的自定义编辑文本(如 NeverEnabledEditText),或者将所有这些属性添加到我的 xml 中,有没有办法做到以上几点?
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/date_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Date"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/tv_date"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="none"
android:clickable="true"
android:focusable="false"
android:drawableEnd="@drawable/ic_keyboard_arrow_down_black_24dp"
android:paddingEnd="4dp"
android:paddingVertical="12dp"
android:drawablePadding="4dp"
android:textColor="@color/colorPrimary"
tools:text="00/00/0000" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
虽然是 TextInputEditText,但现在它的行为就像文本视图,因为您无法编辑它,但可以为其设置文本。不客气 !