下午好,我正在尝试创建带有阴影的 en ImageButton。
这样做:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="5sp">
<ImageButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/circle_shape_little"
android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:elevation="3sp"/>
</LinearLayout>
但这是结果:
如你所见,边框被“切割”了,我不知道为什么。
有人能帮帮我吗?谢谢。
最佳答案
将 layout_margin
添加到您的 ImageButton
。 elevation
阴影被裁剪到 View
的边缘(默认为零):
<ImageButton
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_margin="5dp"
android:background="@drawable/circle_shape_little"
android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:elevation="3dp"/>
或者,您可以设置 View 的 padding
并设置 clipToPadding="false"
,但这可能会导致意外结果,具体取决于您的布局。
最后,你should be对除 textSize
之外的所有内容使用 dp
,在这种情况下,您将使用 sp
。
关于android - ImageButton 提升问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38722902/