【问题标题】:Clip FrameLayout contents to background drawable将 FrameLayout 内容剪辑到背景可绘制对象
【发布时间】:2018-04-21 15:15:10
【问题描述】:

我有一个FrameLayout,其中包含一个LinearLayout、一个TextView 和2 个具有不同背景颜色的Views。 FrameLayout 有一个背景可绘制对象,它是一个浅黄色圆角矩形。

我希望最后一个View(深黄色)被背景可绘制对象剪裁,即FrameLayout 的底部应该有圆角。

如何做到这一点?只能通过 XML 完成吗?

图片来说明问题:

【问题讨论】:

    标签: android android-layout android-linearlayout android-framelayout


    【解决方案1】:

    您可以制作不同的 XML 并应用于框架布局。 XML 代码如下。

    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle" >
        <corner
            android:bottomLeftRadius="Any integer value"
            android:bottomRightRadius="Any integer value" />
    </shape> 
    

    【讨论】:

    • 我打算做一个可滚动的列表,所以列表的内容也应该剪到角落里。
    【解决方案2】:

    我最终将CardViewapp:cardCornerRadius="40dp" 一起使用。

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="wrap_content"
        android:layout_height="300dp"
        android:background="#FFA737"
        app:cardCornerRadius="40dp">
    

    【讨论】:

      猜你喜欢
      • 2016-02-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-08
      • 2013-08-28
      • 2013-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多