zoukankan      html  css  js  c++  java
  • 带圆角的EditText

    转载请注明出处:http://blog.csdn.net/krislight/article


    1.定义一个Drawable

    <?xml version="1.0" encoding="utf-8"?>
    <!--  res/drawable/rounded_edittext.xml -->
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp">
     <solid android:color="#FFFFFF"/>
        <corners
         android:bottomRightRadius="15dp"
         android:bottomLeftRadius="15dp"
      android:topLeftRadius="15dp"
      android:topRightRadius="15dp"/>
    </shape>


    2.布局文件

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <EditText  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:padding="5dip"
        android:background="@drawable/rounded_edittext" />
    </LinearLayout>


    如果要使用多个不同状态下的EditText点击效果

    1.定义一个selector

    <?xml version="1.0" encoding="utf-8"?>
    <!-- res/drawable/rounded_edittext_states.xml -->
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item 
         android:state_pressed="true" 
         android:state_enabled="true"
            android:drawable="@drawable/rounded_focused" />
        <item 
         android:state_focused="true" 
         android:state_enabled="true"
            android:drawable="@drawable/rounded_focused" />
        <item 
         android:state_enabled="true"
            android:drawable="@drawable/rounded_edittext" />
    </selector>

    2.定义Drawable

    <?xml version="1.0" encoding="utf-8"?>
    <!-- res/drawable/rounded_edittext_focused.xml -->
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp">
     <solid android:color="#FFFFFF"/>
     <stroke android:width="2dp" android:color="#FF0000" />
        <corners
         android:bottomRightRadius="15dp"
         android:bottomLeftRadius="15dp"
      android:topLeftRadius="15dp"
      android:topRightRadius="15dp"/>
    </shape>


    3.布局文件

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    <EditText  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        android:background="@drawable/rounded_edittext_states"
        android:padding="5dip"/>
    </LinearLayout>



  • 相关阅读:
    mysql代码实现hive中的rank()排序方法,获得top3中的最小值
    MySQL--Hive中字段数据类型对比
    使用shell脚本连接mysql shell脚本执行mysql语句
    WPS中查看超链接后返回超链接位置
    shell脚本中常用的命令
    Lamda一行代码实现"36选7"随机自动选号
    创建Visual studio项目模板 vstemplate关键点纪要
    网络传输及数据解析
    动画
    触摸事件与手势识别
  • 原文地址:https://www.cnblogs.com/krislight1105/p/3748320.html
Copyright © 2011-2022 走看看