我的 Root View (线性:垂直)中有一个 FrameLayout,我用它来根据用户输入保存不同的 fragment 。 FrameLayout 比背景小,所以它看起来是“ float 的”。
如何使 FrameLayout 的角变圆?
进入 FrameLayout 的 fragment 不是图片,所以我无法裁剪它们。
最佳答案
创建一个 xml 文件,例如your_rounded_shape.xml
,在你的drawable文件夹中添加如下代码:
<?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>
然后使用 your_rounded_shape.xml
作为 FrameLayout
的背景。像这样:
<FrameLayout
android:width="match_parent"
android:height="wrap_content"
android:background="@drawable/your_rounded_shape"/>
关于android - 带圆角的 FrameLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36208320/