控制边框形状,先在drawable中建一个xml文件:shape.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <shape xmlns:android="http://schemas.android.com/apk/res/android"> 3 <solid android:color="#00ff00ff"/> 4 <corners android:radius="8px"/> 5 <stroke android:color="#32CD32" 6 android:width="2px" 7 /> 8 </shape>
然后是布局文件,可以控制EditText的图标、字体颜色、光标、hint字体
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" 5 android:background="@drawable/bg" 6 android:orientation="vertical" > 7 8 9 <EditText 10 android:layout_width="200dp" 11 android:layout_height="wrap_content" 12 android:layout_gravity="center" 13 android:drawableLeft="@drawable/title" //框内图标 14 android:background="@drawable/shape" //边框形状 15 android:padding="5px" 16 android:hint="请输入用户名" 17 android:singleLine="true" 18 android:textCursorDrawable="@null" //光标颜色 19 android:textColor="#4e4d4d"/> 20 21 </LinearLayout> 22
时间: 2024-10-07 05:06:36