一.给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来实现
时间: 2024-11-03 17:06:28