android MD2输入框样式
先上图
上代码:
style
<resources xmlns:tools="http://schemas.android.com/tools"> <!-- Base application theme. --> <style name="Theme.Susenet" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <!-- Primary brand color. --> <item name="colorPrimary">@color/purple_500</item> <item name="textInputStyle">@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox </item> <item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorOnPrimary">@color/white</item> <!-- Secondary brand color. --> <item name="colorSecondary">@color/teal_200</item> <item name="colorSecondaryVariant">@color/teal_700</item> <item name="colorOnSecondary">@color/black</item> <!-- Status bar color. --> <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> <!-- Customize your theme here. --> </style> </resources>
布局文件.xml
<com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/pwd" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="密码" /> </com.google.android.material.textfield.TextInputLayout>
搞定:
<com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/pwd" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="密码" /> </com.google.android.material.textfield.TextInputLayout>