android 圆角编辑框

main.xml:

  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. >
  7. <TextView
  8. android:layout_width="fill_parent"
  9. android:layout_height="wrap_content"
  10. android:gravity="center_horizontal"
  11. android:text="圆角编辑框"
  12. />
  13. <LinearLayout
  14. android:layout_width="fill_parent"
  15. android:layout_height="wrap_content"
  16. android:gravity="center_horizontal"
  17. android:orientation="horizontal">
  18. <EditText
  19. android:layout_width="220px"
  20. android:layout_height="wrap_content"
  21. android:padding="5px"
  22. android:background="@drawable/rounded_edittext_states"
  23. android:drawableLeft="@drawable/search"
  24. android:singleLine="true"
  25. android:lines="1"
  26. />
  27. <Button
  28. android:layout_width="wrap_content"
  29. android:layout_height="wrap_content"
  30. android:background="@drawable/button_search_bg"
  31. />
  32. </LinearLayout>
  33. </LinearLayout>

rounded_edittext_states.xml :

  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <!--res/drawable-hdpi/rounded_edittext_states.xml-->
  3. <selectorxmlns:android="http://schemas.android.com/apk/res/android">
  4. <item
  5. android:state_pressed="true"
  6. android:state_enabled="true"
  7. android:drawable="@drawable/rounded_focused"/>
  8. <item
  9. android:state_focused="true"
  10. android:state_enabled="true"
  11. android:drawable="@drawable/rounded_focused"/>
  12. <item
  13. android:state_enabled="true"
  14. android:drawable="@drawable/rounded_edittext"/>
  15. </selector>

rounded_edittext.xml :

  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <!--res/drawable/rounded_edittext.xml-->
  3. <shapexmlns:android="http://schemas.android.com/apk/res/android"
  4. android:shape="rectangle"
  5. android:padding="8dip">
  6. <solidandroid:color="#FFFFFF"/>
  7. <corners
  8. android:bottomRightRadius="10dip"
  9. android:bottomLeftRadius="10dip"
  10. android:topLeftRadius="10dip"
  11. android:topRightRadius="10dip"/>
  12. </shape>

rounded_edittext_focused.xml :

  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <!--res/drawable/rounded_edittext_focused.xml-->
  3. <shapexmlns:android="http://schemas.android.com/apk/res/android"
  4. android:shape="rectangle"
  5. android:padding="8dip">
  6. <solidandroid:color="#FFFFFF"/>
  7. <strokeandroid:width="2dip"android:color="#999"/>
  8. <corners
  9. android:bottomRightRadius="10dip"
  10. android:bottomLeftRadius="10dip"
  11. android:topLeftRadius="10dip"
  12. android:topRightRadius="10dip"/>
  13. </shape>

工程源码:http://download.csdn.net/source/3409407


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值