【发布时间】:2021-03-07 04:36:09
【问题描述】:
我想在TextInputLayout 上全局设置自定义样式为:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.BudgetTracker" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
...
<!-- Secondary brand color. -->
...
<!-- Status bar color. -->
...
<!-- Customize your theme here. -->
<item name="fontFamily">@font/regular</item>
<!-- TextInputLayout-->
<item name="textInputStyle">@style/Widget.MyNiceAppName.TextInputLayout.OutlinedBox</item>
</style>
<style name="Widget.MyNiceAppName.TextInputLayout.OutlinedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="android:imeOptions">actionNext</item>
<item name="android:maxLines">1</item>
</style>
</resources>
我的片段布局是
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/outlinedTextField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="32dp"
android:hint="@string/label_email"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/acll">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
但它永远不会起作用。非常感谢任何有关上述问题解决的建议。
【问题讨论】:
-
我在我的应用程序中尝试了相同的代码,它成功了。是不是“maxlines”似乎不适合你?
-
谢谢,但在我这边
android:imeOptions和android:maxLines都不起作用。
标签: android material-design material-components-android android-textinputlayout