首先創建/res/drawable/roundcorner.xml文件.
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:padding="5dp" android:shape="rectangle" > <solid android:color="#B0B0B0" /> <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" /> </shape>
在佈局文件, 設置android:background="@drawable/roundcorner".
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10sp" android:drawablePadding="5dp" android:drawableStart="@drawable/ic_launcher" android:gravity="left|bottom" android:textColor="#F0F0F0" android:background="@drawable/roundcorner" android:hint="hello" > </EditText> </LinearLayout>
沒有留言:
發佈留言