RecyclerView 四周圆角显示控制,最大高度扩展

1、依赖引用CardView 方式

1.1 添加CardView依赖

	implementation 'androidx.cardview:cardview:1.0.0'

1.2 常用属性

	// 阴影的大小
	app:cardElevation 
	// 阴影最大高度
	app:cardMaxElevation 
	// 卡片的背景色
	app:cardBackgroundColor 
	// 卡片的圆角大小
	app:cardCornerRadius 
	// 卡片内容于边距的间隔
	app:contentPadding 
	// 设置content内边距
	app:contentPaddingBottom
	app:contentPaddingTop
	app:contentPaddingLeft
	app:contentPaddingRight
	app:contentPaddingStart
	app:contentPaddingEnd
	// 设置内边距,V21+的版本和之前的版本仍旧具有一样的计算方式
	app:cardUseCompatPadding 
	// 在V20和之前的版本中添加内边距,这个属性为了防止内容和边角的
	app:cardPreventConrerOverlap

1.3 Tips

	// 设置圆角
	app:cardCornerRadius
	
	// 设置背景颜色,这里设置背景不是setBackground!!!
	app:cardBackgroundColor
	
	// 添加padding
	app:cardUseCompatPadding
	
	// 解决CardView四个角有灰色阴影的问题
	app:cardElevation="0dp"
	
	// CardView 5.0以下出现内边距问题,去掉自动添加的padding
	cardPreventCornerOverlap = "false"

1.4 组件使用

<androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="6dp"
            app:cardElevation="0dp">

            <androidx.appcompat.widget.LinearLayoutCompat
                callType="@{viewModel.curCallType}"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center_horizontal"
                android:orientation="vertical"
                tools:background="@color/c_D61518">

                <View
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1" />

                <com.witted.door.ui.zjs.view.CallInfoLayout
                    android:id="@+id/CallInfo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

                <!--来电状态的按钮显示-->
                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="60dp"
                    android:visibility="@{!viewModel.callingState}"
                    app:layout_constraintTop_toBottomOf="@id/CallInfo">

                    <androidx.constraintlayout.widget.Guideline
                        android:id="@+id/vGuideLine"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        app:layout_constraintGuide_percent="0.5" />

                    <ImageView
                        android:id="@+id/ivCancel"
                        clickListener="@{viewModel::refuse}"
                        android:layout_width="64dp"
                        android:layout_height="64dp"
                        android:layout_marginEnd="50dp"
                        android:background="@drawable/sel_call_refuse"
                        app:layout_constraintEnd_toStartOf="@id/vGuideLine"
                        app:layout_constraintHorizontal_chainStyle="packed"
                        app:layout_constraintTop_toTopOf="parent" />

                    <</
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值