【问题标题】:Applying the rounded corners to a CardView inner element将圆角应用于 CardView 内部元素
【发布时间】:2018-12-01 03:25:56
【问题描述】:

我有一个内部布局的 CardView,其背景颜色与 CardView 不同。我希望内部布局与 CardView 的一侧对齐,并采用该侧的 2 个圆角。

 <android.support.v7.widget.CardView
            android:layout_alignParentBottom="true"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_marginBottom="@dimen/activity_horizontal_margin"
            android:layout_marginRight="30dp"
            app:cardCornerRadius="20dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:text="Pediatric Drugs"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:padding="10dp"
                    android:background="@color/colorPrimary"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="HELLO"
                        android:textColor="@color/white"
                        android:textStyle="bold"
                        />
                </LinearLayout>

            </RelativeLayout>
        </android.support.v7.widget.CardView>

【问题讨论】:

    标签: java android xml android-cardview


    【解决方案1】:

    我通过为内部布局设置自定义背景解决了这个问题,其顶部和底部半径值与 CardView 半径值相同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-28
      相关资源
      最近更新 更多