android:radius不起作用或只有部分角起作用

讨论了部分手机上按钮出现的bug问题,原因在于子控件中某些控件的宽度设置为match_parent。建议使用RelativeLayout并设置特定drawable背景来解决此问题。

原因是子控件里有部分控件的宽度是match_parent,部分手机的bug,暂时无解,有解决方法的朋友还请多多提点。

最常见的就是button出现这种bug,外面套一层RelativeLayout,然后让这个RelativeLayout使用该drawable背景,应该可以解决。

<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <com.tplink.omada.common.views.TPNetRadiusCardView android:id="@+id/header" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:rcv_tlRadius="@dimen/tpds_all_dp_10" app:rcv_trRadius="@dimen/tpds_all_dp_10" android:background="@color/color_card"> <View android:id="@+id/overview_title" android:background="@drawable/skeleton_rounded_background" android:layout_width="180dp" android:layout_height="20dp" android:layout_marginHorizontal="?layoutItemHorizontalMargin" android:layout_marginTop="@dimen/tpds_all_dp_16" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/activity_horizontal_margin" android:layout_marginEnd="@dimen/tpds_all_dp_16" app:layout_constraintTop_toBottomOf="@id/overview_title" android:layout_marginTop="@dimen/tpds_all_dp_32"> <View android:id="@+id/traffic_pie_chart" android:layout_width="@dimen/tpds_all_dp_120" android:layout_height="@dimen/tpds_all_dp_120" android:layout_centerVertical="true" android:background="@drawable/skeleton_rounded_background" /> <LinearLayout android:id="@+id/recycler" android:layout_width="0dp" android:layout_height="wrap_content" android:orientation="vertical" android:layout_marginVertical="@dimen/tpds_all_dp_32" android:layout_marginEnd="@dimen/tpds_all_dp_32" android:visibility="visible" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_marginStart="@dimen/tpds_all_dp_24" android:layout_marginTop="@dimen/tpds_all_dp_24" android:layout_toEndOf="@+id/traffic_pie_chart" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <View android:id="@+id/view1" android:layout_width="40dp" android:layout_height="18dp" android:layout_marginStart="10dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentStart="true" /> <View android:id="@+id/view2" android:layout_width="20dp" android:layout_height="18dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentEnd="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp"> <View android:layout_width="40dp" android:layout_height="18dp" android:layout_marginStart="10dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentStart="true" /> <View android:layout_width="20dp" android:layout_height="18dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentEnd="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp"> <View android:layout_width="40dp" android:layout_height="18dp" android:layout_marginStart="10dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentStart="true" /> <View android:layout_width="20dp" android:layout_height="18dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentEnd="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp"> <View android:layout_width="40dp" android:layout_height="18dp" android:layout_marginStart="10dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentStart="true" /> <View android:layout_width="20dp" android:layout_height="18dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentEnd="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp"> <View android:layout_width="40dp" android:layout_height="18dp" android:layout_marginStart="10dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentStart="true" /> <View android:layout_width="20dp" android:layout_height="20dp" android:background="@drawable/skeleton_rounded_background" android:layout_alignParentEnd="true" /> </RelativeLayout> </LinearLayout> </RelativeLayout> </com.tplink.omada.common.views.TPNetRadiusCardView> <com.tplink.omada.common.views.TPNetRadiusCardView android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@+id/header" app:layout_constraintStart_toStartOf="@+id/header" android:layout_marginTop="@dimen/tpds_all_dp_16" app:rcv_tlRadius="@dimen/tpds_all_dp_10" app:rcv_trRadius="@dimen/tpds_all_dp_10"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="?attr/layoutItemHorizontalMargin" android:layout_marginTop="?attr/cardWithCardMargin" android:layout_marginEnd="?attr/layoutItemHorizontalMargin" app:layout_constraintTop_toTopOf="parent" android:orientation="vertical" android:background="@color/color_card"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/tab" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@+id/card_title_layout" android:layout_marginTop="18dp" android:paddingStart="6dp" android:paddingEnd="6dp"> <View android:id="@+id/left_view" android:layout_width="60dp" android:layout_height="20dp" android:background="@drawable/skeleton_rounded_background" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/right_view" app:layout_constraintHorizontal_bias="0.5" /> <View android:id="@+id/right_view" android:layout_width="60dp" android:layout_height="20dp" android:background="@drawable/skeleton_rounded_background" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/left_view" app:layout_constraintHorizontal_bias="0.5" /> </androidx.constraintlayout.widget.ConstraintLayout> <com.google.android.material.chip.ChipGroup android:id="@+id/chip_group_app" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="?attr/layoutItemHorizontalMargin" android:layout_marginEnd="?attr/layoutItemHorizontalMargin" android:layout_marginTop="@dimen/tpds_all_dp_16" android:layout_marginBottom="@dimen/tpds_all_dp_10" app:layout_constraintTop_toBottomOf="@id/tab_layout" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:checkedChip="@id/all_ll" app:selectionRequired="true" app:singleLine="true" app:singleSelection="true"> <com.google.android.material.chip.Chip android:id="@+id/chip_allow" style="@style/Widget.APP.Chip" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <com.google.android.material.chip.Chip android:id="@+id/chip_block" style="@style/Widget.APP.Chip" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </com.google.android.material.chip.ChipGroup> <include layout="@layout/skeleton_statistics_traffic_item"/> <include layout="@layout/skeleton_statistics_traffic_item"/> <include layout="@layout/skeleton_statistics_traffic_item"/> <include layout="@layout/skeleton_statistics_traffic_item"/> <include layout="@layout/skeleton_statistics_traffic_item"/> <include layout="@layout/skeleton_statistics_traffic_item"/> <include layout="@layout/skeleton_statistics_traffic_item"/> </LinearLayout> </com.tplink.omada.common.views.TPNetRadiusCardView> </androidx.constraintlayout.widget.ConstraintLayout>这个线性布局里得东西为什么不显示
最新发布
10-17
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ithouse

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值