Android Button的小小美化

原始的Button长这样:

drawable文件夹下新建一个xml文件,就取名为background_startanewchat.xml吧

<?xml version="1.0" encoding="utf-8"?>
<!-- rectangle表示为矩形 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <!-- 设置上下左右内边距
         top:上内边距
         bottom:下内边距
         left:左内边距
         right:右内边距
     -->
    <padding
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp"
        />

    <!-- 设置圆角矩形
         radius:圆角弧度,核心代码
    -->
    <corners android:radius="30dp" />

    <!-- 设置描边效果
         width:描边宽度
         color:描边颜色
     -->

    <!-- 设置填充效果
         color:填充颜色
     -->
    <solid android:color="#009688"/>

</shape>

将button的background设置为这个xml文件:

<Button
            android:text="开始新的聊天?"
            android:background="@drawable/background_startanewchat"
            android:id="@+id/btn_startnewchat"/>
            

新button效果:

看起来稍微好...了一点?甚至还有点立体感。

 

posted @ 2024-03-13 23:03  拾一贰叁  阅读(43)  评论(0编辑  收藏  举报