MaterialComponents.TextInputLayout.OutlinedBox无法正常工作boxBackgroundColor

问题描述 投票:2回答:2

我使用材料。我将为背景的TextInputLayout使用一种颜色,但类似于下面的颜色!提示背景未更改。我使用了样式并想进行更改,但没有用。在布局本身中,我尝试再次应用更改!如何解决此问题?

NOTE

标签用户名的背景,而不是透明,并且覆盖一些TextInputEditTextenter image description here

build.gradle

]中>implementation 'com.google.android.material:material:1.1.0'
in 

style

<!-- Base application theme. --> <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="textAppearanceSubtitle1">@style/TextAppearance.App.Subtitle1</item> <item name="textAppearanceCaption">@style/TextAppearance.App.Caption</item> <item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.App.SmallComponent</item> </style> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar"/> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light"/> <style name="TextAppearance.App.Subtitle1" parent="TextAppearance.MaterialComponents.Subtitle1"> <item name="colorControlActivated">@color/white</item> <item name="android:colorControlActivated">@color/white</item> </style> <style name="TextAppearance.App.Caption" parent="TextAppearance.MaterialComponents.Caption"> <item name="android:textColorTertiary">@color/white</item> <item name="android:textColorTertiaryInverse">@color/white</item> <item name="colorControlActivated">@color/white</item> <item name="android:colorControlActivated">@color/white</item> </style> <style name="ShapeAppearance.App.SmallComponent" parent="ShapeAppearance.MaterialComponents.SmallComponent"> <item name="cornerFamily">rounded</item> <item name="cornerSize">16dp</item> <item name="colorControlActivated">@color/white</item> <item name="android:colorControlActivated">@color/white</item> </style>

布局

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/gray" android:gravity="center" android:orientation="vertical" android:padding="32dp"> <com.google.android.material.textfield.TextInputLayout android:id="@+id/linUsername" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:hint="@string/label_username" android:textColorHint="#AEB0C6" app:boxBackgroundColor="#33385E" app:boxStrokeColor="@color/red" app:endIconDrawable="@drawable/ic_clear_white_24dp" app:endIconMode="password_toggle" app:endIconTint="#AEB0C6" app:hintTextColor="#AEB0C6" app:startIconDrawable="@drawable/ic_info_outline_white_24dp" app:startIconTint="#AEB0C6"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/edtUsername" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPersonName" android:textColor="@color/white" android:textColorHint="@color/white" app:hintTextColor="#AEB0C6" /> </com.google.android.material.textfield.TextInputLayout> <com.google.android.material.button.MaterialButton android:id="@+id/btnSelectText" android:layout_width="168dp" android:layout_height="wrap_content" android:layout_marginTop="24dp" android:fontFamily="@font/iran_sans_mobile" android:text="login" android:visibility="visible" app:cornerRadius="@dimen/radiusButton" /> </LinearLayout>
我使用材料。我将为背景的TextInputLayout使用一种颜色,但类似于下面的颜色!提示背景未更改。我使用了样式并想进行更改,但没有用。 ...
android material-design android-textinputlayout android-textinputedittext
2个回答
1
投票
您可以使用带边框的自定义编辑文本,因此可以轻松设置所需的背景。例如,尝试以下代码:activity_main.xml

0
投票
如果您不喜欢使用自定义编辑文本,则可以通过以下方式修改代码:
© www.soinside.com 2019 - 2024. All rights reserved.