How to enlarge shadow radius for a view

时间:2018-03-06 18:21:35

标签: java android android-layout android-drawable shadow

I have a ImageView that I want to add a shadow to it, but with a large radius area.!

I tried using elevation but it doesn't seem to increase the radius very much..!

I also tired using xml drawable shape but with no luck. Here's an example of what I want to achieve. assuming the white circle is the image.

enter image description here

中剥离文字

2 个答案:

答案 0 :(得分:1)

I tried using elevation but it doesn't seem to increase the radius very much..!

我认为 ImageView 没有实现elevation属性,你可以只写属性,因为 ImageView 是来自 View的子类 class。

如果您需要实现该高程并获得阴影,请使用FloatingActionButton进行操作,或者如果您不需要使用FloatingActionButton并继续使用ImageView,则必须设置CardView 1}}作为ImageView的容器,并将高程添加到CardView

答案 1 :(得分:0)

我会通过使用CardView(在Lollipop或更高版本上来解决这个问题;前Lollipop,这不会起作用):

<android.support.v7.widget.CardView
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:layout_gravity="center"
    app:cardElevation="20dp"
    app:cardCornerRadius="24dp">

    <ImageView
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:padding="12dp"
        app:srcCompat="@drawable/ic_arrow_back_24dp"/>

</android.support.v7.widget.CardView>

enter image description here