因为美观需要,需要定制一些圆角的Button,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>
最后
运行一下,没毛病的话应该像上面那样,有毛病的话我也不知道