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>



  • 相关阅读:
    redis cluster 6.2集群
    RocketMQ多master多salve集群搭建
    等保审核 --- MySQL密码复杂度--和连接错误超时等
    centos7.5升级系统内核版本
    MHA架构的实现方式
    使用pip的方式安装docker-compose
    MySQL备份每一个数据库为单独的sql压缩文件,并且保留最近一个月的备份文件
    SpringCloud组件编写Dockerfile文件模板
    火狐浏览器经常使用的插件
    docker 查询或获取私有仓库(registry)中的镜像
  • 原文地址:https://www.cnblogs.com/krislight1105/p/3748320.html
Copyright © 2011-2022 走看看