android Button 如何设置border 效果, 如下图

android button border 效果如何设置.
图片描述

阅读 22.4k
3 个回答

drawable里做一个类似于这样的你看能不能行,background设为引用这个@drawable/xxx

xml<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners -- 四个角的圆角半径,左边右边中间的区别就是在这里体现的
        android:topLeftRadius="5dp"
        android:bottomLeftRadius="5dp" 
        android:topRightRadius="0.1dp"
        android:bottomRightRadius="0.1dp" />

    <stroke    -- 指定边框,边框必须要的
        android:width="0.5dp"
        android:color="#0000ff" />
    <solid    -- 填充颜色,选中和未选中的区别就在这里还有文字颜色
        android:color="#0000ff" />
</shape>

可以自定义圆角属性,也可以用元角背景图

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题