定制圆角EditText与圆角Button

因为美观需要,需要定制一些圆角的Button,EditText,像下面这样
editText这里写图片描述
本渣对这种东西就是没啥美感,既然老大要求,那就学习了一下

首先

当然是先把EditText这个东西给写出来

EditText

 <EditText
                android:layout_marginLeft="10dp"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="陈同学"
                android:background="@drawable/edittextsharp"/>

Button

 <Button
        android:id="@+id/logIn_btn_WebLogin"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/buttonsharp"
        android:text="微博登陆(WebView)"
        android:textAllCaps="false"
        android:textColor="@android:color/white" />

然后

有没有注意到我用的背景backgrou是@drawable里的资源,没错,确实是在@drawable里面做文章,在drawable文件夹目录->new->drawable resource file,代码如下

edittextsharp

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <!--里面空间的属性-->
    <solid
        android:color="#e2e2e2" >
    </solid>
    <!--圆角的半径-->
    <corners
        android:radius="3dp">
    </corners>
    <!--边的属性-->
    <stroke
        android:color="@color/colorPrimary"
        android:width="2dp">
    </stroke>
    <!--控制文字与边框的距离-->
    <padding
        android:left="5dp"
        android:right="5dp"
        android:bottom="5dp"
        android:top="5dp"></padding>
</shape>

buttonsharp

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid
        android:color="@color/colorPrimaryDark">
    </solid>
    <corners
        android:radius="5dp">
    </corners>
</shape>

最后

运行一下,没毛病的话应该像上面那样,有毛病的话我也不知道

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值