android - 带圆角的 FrameLayout

标签 android android-framelayout

我的 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/

相关文章:

android - 使FrameLayout中的LinearLayout不透明

java - Android Paging Library如何知道加载更多数据?

android - 如何处理来自 AccessibilityService 的 MotionEvents(游戏 handle 操纵杆移动等)

android - 更快的 WiFi 扫描速率以获得 rssi 更改 android

java.lang.IllegalStateException : Circular dependencies cannot exist in RelativeLayout : XML

java - 仅显示最后添加的按钮

java - 如何为我的 Android 应用程序实现以下结构?

android - 按钮始终显示在 FrameLayout 的顶部

android - 如何在框架布局或线性布局内创建全屏视频 View

java - getHeight 为所有 Android UI 对象返回 0