ImageButton高程问题 [英] ImageButton elevation issue

查看:107
本文介绍了ImageButton高程问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好,我正在尝试创建带有阴影的en ImageButton.

Good afternoon, I am trying to create en ImageButton with a shadow.

要这样做:

<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>

但这是结果:

如您所见,边界是切割"的,我不知道为什么.

As you can see, the borders are "cut", and I do not know why.

有人可以帮助我吗?谢谢.

Does anyone can help me ? Thank you.

推荐答案

ImageButton中添加layout_margin. elevation阴影被裁剪到View的边缘(默认为零):

Add a layout_margin to your ImageButton. The elevation shadow gets clipped to the margins of the View (which defaults to zero):

<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"/>

或者,您可以设置视图的padding并设置clipToPadding="false",但这可能会导致意外的结果,具体取决于您的布局.

Alternatively, you could set the padding of the view and set clipToPadding="false", but this could lead to unexpected results depending on your layout.

最后,您应该使用textSize以外的所有内容,在这种情况下,您将使用sp.

Lastly, you should be using dp for everything but textSize, in which case you would use sp.

这篇关于ImageButton高程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆