您的位置:首页 > 移动开发 > Android开发

Android 圆角fraagment的实现

2016-07-01 10:29 1726 查看
在drawable里定义好一个布局,命名为 green_bg:代码如下

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

</shape>

在fragment的布局里引用这个定义好的布局

代码如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/green_bg"
>
<TextView
android:text="1"
android:layout_marginLeft="10dp"
android:gravity="center"
android:textColor="#dcd3d3"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:background="#000000"/>

</LinearLayout>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息