android 常用控件归类(二)

android常用控件归类

给大家带来的是Android资源的外形资源(Shape):


所谓的资源都是指res文件夹下的xml文件,每一种类型的xml文件都对应了一种资源



外形资源(Shape): Shape资源用来定义一个基本的几何图形(矩形,圆形,线条等)


属性:   android:shape

取值:rectangle 矩形

    oval  椭圆

    line   直线

    ring   圆环



这些外形资源我定义了一个新的xml      et_shape.xml

<?xml version="1.0" encoding="utf-8"?>
<!--在这里调用 android外形资源-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.android_06_03.MainActivity">


    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

        <EditText
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:hint="请输入你的用户名"
            android:paddingLeft="130dp"
            android:background="@drawable/et_setector"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:text="用户名:"
            android:textSize="20sp"
            android:gravity="center"
            android:drawableLeft="@drawable/icon_user"
            android:paddingLeft="25sp"
            />

    </FrameLayout>
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:hint="请输入你的密码"
            android:paddingLeft="130dp"
            android:inputType="textPassword"
            android:background="@drawable/et_setector"

            />


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:paddingLeft="25sp"
            android:text="    密码:"
            android:textSize="20sp"
            android:gravity="center"
            android:drawableLeft="@drawable/icon_user"

            />
    </FrameLayout>









</LinearLayout>

<!--内部颜色--> <solid android:color="#babec6" ></solid><!--外边框颜色 和宽度--> <stroke android:width="2dp" android:color="#000000" ></stroke> <!--四边的弧度--> <corners android:radius="20dp" ></corners></shape>



在layout里面的xml进行调用


然后结果图如下  


    

图片边距 明显的变成了黑色  ,而且选中文本框也会进行相应的文本框颜色变化

下面是一些其他的控件


<corners /> 定义几何图形四个角的弧度 android:radius  设置四个角的弧度

android:XXXradius  设置一个角的弧度



还有尺寸资源 (Dimension)  dimen标签用于定义尺寸资源

<dimen name=" "></dinmen>



Selector选择器

颜色资源(Color)    作用:在控制控件在不同状态的样式

<item />   android:state_focused=" "   控件的状态     

    获取焦点状态的资源,必须放在第一行

android:drawable=" "   设置对应的资源或者图片



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值