I have an imageView on top a map fragment and I want to create shadow around it to look outstanding but as you may know shadows in android need a background to be applied on while map is not a suitable background. So is there any way to achieve this shadow?
            Asked
            
        
        
            Active
            
        
            Viewed 490 times
        
    0
            
            
        - 
                    https://developer.android.com/training/material/shadows-clipping for API 21+, use elevation property – CSmith Nov 16 '18 at 12:54
 - 
                    `"but as you may know shadows in android need a background"` what do you mean by that? – pskink Nov 16 '18 at 13:09
 - 
                    I mean if a view doesn't have a background, then the elevation wouldn't show shadow. – therealak12 Nov 16 '18 at 13:48
 
2 Answers
0
            
            
        You can create CardView as wrapper for image view. Like that.
Or create a drawable and set to your image view as android:background. Like that.
Or check documentation.
        Onix
        
- 662
 - 3
 - 10
 
0
            
            
        You can achieve it like this
<android.support.v7.widget.CardView
                    android:id="@+id/imgWrapper"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    card_view:cardCornerRadius="5dp"
                    card_view:cardElevation="5dp">
                    <ImageView
                        android:id="@+id/image"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:src="@drawable/your_drawable" />
                </android.support.v7.widget.CardView>
Just place your imageView inside the card with having elevations like above.
        Abid Khan
        
- 2,451
 - 4
 - 22
 - 45
 
- 
                    I dont't know how your are doing but the shadow should work both by using drawable or cardview whether its a map or any other layout as background. – Abid Khan Nov 16 '18 at 14:55