Android 圆角框架布局
我在根视图(线性:垂直)中有一个框架布局,用于根据用户输入保存不同的片段。FrameLayout比背景小,因此看起来是“浮动的” 如何使框架布局的各个角变圆Android 圆角框架布局,android,android-framelayout,Android,Android Framelayout,我在根视图(线性:垂直)中有一个框架布局,用于根据用户输入保存不同的片段。FrameLayout比背景小,因此看起来是“浮动的” 如何使框架布局的各个角变圆 框架布局中的碎片不是图片,所以我不能裁剪它们 在可绘图文件夹中创建一个xml文件,例如您的\u rounded\u shape.xml,并添加以下代码: <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android=&quo
框架布局中的碎片不是图片,所以我不能裁剪它们 在可绘图文件夹中创建一个xml文件,例如
您的\u rounded\u shape.xml
,并添加以下代码:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#CCCCCC"/>
<stroke android:width="2dp"
android:color="#999999"/>
<padding android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/>
<corners android:radius="8dp" />
</shape>
将框架布局替换为CardView布局
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp">
</android.support.v7.widget.CardView>
只是对上述答案的改进: 这个xml文件的名称,比如说
rounded\u frame\u layout.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#CCCCCC"/>
<stroke android:width="2dp"
android:color="#999999"/>
<padding android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/>
<corners android:radius="8dp"/>
</shape>
Then use your drawable as follows:
<FrameLayout
android:width="match_parent"
android:height="wrap_content"
android:background="@drawable/rounded_frame_layout"/>
然后按如下方式使用您的绘图工具:
这太完美了!谢谢你,这正是我想要的。你不能把一个手工制作的可绘制的东西作为你的框架布局的背景吗?这使得形状不能重复使用
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#CCCCCC"/>
<stroke android:width="2dp"
android:color="#999999"/>
<padding android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/>
<corners android:radius="8dp"/>
</shape>
Then use your drawable as follows:
<FrameLayout
android:width="match_parent"
android:height="wrap_content"
android:background="@drawable/rounded_frame_layout"/>