Android 圆角fraagment的实现

来源:互联网 发布:菜刀三国杀淘宝 编辑:程序博客网 时间:2024/06/06 03:48

在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>

1 0
原创粉丝点击