美文网首页
android 背景边框变圆角的几种方法

android 背景边框变圆角的几种方法

作者: babybus_hentai | 来源:发表于2016-06-23 10:32 被阅读3894次

转载:blog.csdn.net/swust_chenpeng/article/details/11597165

第一种方法:在drawable文件夹下新建一个文件设置背景样式

代码:

在drawable文件夹下面新建text_view_border.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#80858175" />
<stroke android:width="1dip" android:color="#aea594" />
<corners android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomRightRadius="2dp"
android:bottomLeftRadius="2dp"/>
</shape>

在布局文件调用

<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/text_view_border" />

tv.setBackgroundResource(R.drawable.text_view_border);
分析:

solid设置填充颜色,颜色值以#80开头表示透明

stroke 设置边框宽度,颜色值

corners设置圆角

第二种方法:用图片设置background

相关文章

网友评论

      本文标题: android 背景边框变圆角的几种方法

      本文链接:https://www.haomeiwen.com/subject/fbbndttx.html