Android?attr/SelectableItemBackground无边框外观为方形而非圆形
我使用的是Android支持库版本27.0.2。根据API 23进行测试。AndroidAndroid?attr/SelectableItemBackground无边框外观为方形而非圆形,android,material-design,android-imagebutton,Android,Material Design,Android Imagebutton,我使用的是Android支持库版本27.0.2。根据API 23进行测试。AndroidSelectableItemBackgroundless过去是圆形的。但在我的情况下,我不知道怎么了 `<RelativeLayout android:id="@+id/vgSharePostHeader" android:layout_width="match_parent" android:background="@color/white" android:layou
SelectableItemBackgroundless
过去是圆形的。但在我的情况下,我不知道怎么了
`<RelativeLayout
android:id="@+id/vgSharePostHeader"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="@dimen/clickable_size_48">
<ImageButton
android:id="@+id/ibSharePostCloseDialog"
android:layout_width="@dimen/clickable_size_32"
android:layout_height="@dimen/clickable_size_32"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/item_gap_l"
android:background="?attr/selectableItemBackgroundBorderless" << HERE
android:src="@drawable/ic_close_black_24dp"
android:tint="@color/gray_text" /> ...
`
您需要在ImageButton
版面_边距应大于或等于(√2*layout_width-layout_width)/2
这样就可以完全绘制SelectableItemBackgroundless
如果clickable\u size\u 32
为32dp
,layout\u margin
将为(√2*32-32)/2=6.8
那么您的ImageView
应该如下所示-
<ImageButton
android:id="@+id/ibSharePostCloseDialog"
android:layout_width="@dimen/clickable_size_32"
android:layout_height="@dimen/clickable_size_32"
android:layout_centerVertical="true"
android:layout_margin="7dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_close_black_24dp"
android:tint="@color/gray_text" />
我真的不知道android:hardwareAccelerated=“false”
在Manifest.xml上,所有?attr/selectableitemsbackgroundless
都被破坏
为了解决这个问题,我只需从
application
标签中删除android:hardwareAccelerated=“false”
。它看起来已经超出了范围。您在哪个API级别进行了测试?显示您的代码。显示您的xml代码我已经更新了我的问题。您是否解决了此问题?OP想要无限的涟漪。不幸的是android:attr/selectableItemBackground
将我的ImageButton
设置为方形。我希望它是图2所示的圆圈。是否有可能其他依赖项在android:attr/selectableItemBackground
上产生平方涟漪?因为这是正常的(圆形波纹)。如果可能的话,那么如何跟踪导致此问题的第三方依赖关系?