一.給EditText添加背景,並且4角圓弧

對應的xml 以及樣式如下:
<EditText android:id="@+id/o_item_num" style="@style/ValueTextStyle" android:hint="請輸入服務次數" android:layout_height="40.0dip" android:inputType="number" android:singleLine="true" android:text="1" />
<style name="ValueTextStyle"> <item name="android:textSize">@dimen/txt_m</item> <item name="android:background">@drawable/edit_bg_selector</item> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_marginLeft">15.0dip</item> <item name="android:layout_marginTop">10.0dip</item> <item name="android:layout_marginRight">15.0dip</item> <item name="android:layout_marginBottom">10.0dip</item> <item name="android:layout_centerVertical">true</item> </style>
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/edit_text_disable" /> <item android:state_focused="true" android:drawable="@drawable/edit_text_focused" /> <item android:state_pressed="true" android:drawable="@drawable/edit_text_focused" /> <item android:drawable="@drawable/edit_text" /> </selector>
當然還有一種方式是定義 圓弧 shape來實現
