(1 screenshot - ImageView visibility is visible, 2 screenshot - gone)
When using ImageView
with CardView
we can say that shadow isn't visible at all (especially on the smartphone display)
<android.support.v7.widget.CardView
android:id="@+id/ImageViewWrapper"
android:layout_width="0dp"
android:layout_height="0dp"
android:elevation="0dp"
android:layout_margin="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:cardCornerRadius="6dp">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/ImageView"
android:visibility="visible"
android:background="@color/black_1000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
app:srcCompat="@drawable/ic_folder"/>
</android.support.v7.widget.CardView>
android:elevation
doesn't make any effect (0dp, 5dp, or 20dp - nothing changes), so I just set it 0dp
Can we control this cardview shadow, make it stronger/bigger/thicker?
3 screenshot - here MX Player app example of video thumbnail ImageView (https://play.google.com/store/apps/details?id=com.mxtech.videoplayer.ad)
Update
I set app:cardElevation="7dp"
and app:cardUseCompatPadding="true"
No progress... and cardUseCompatPadding
made my image height size smaller and now I have black bars at left/right
CardView is a new widget in Android that can be used to display any sort of data by providing a rounded corner layout along with a specific elevation. CardView is the view that can display views on top of each other. The main usage of CardView is that it helps to give a rich feel and look to the UI design.
Use Fake Shadow. xml ) in the parent layout which is looking like a shadow. You can replace FF46A9 in shadow. xml to change the color of shadow. Also android:backgroundTint="@color/colorShadow" works but you have to adjust colors alpha in shadow.
Use app:cardElevation="4dp"
instead of android:elevation
.
Also add this app:cardUseCompatPadding="true"
.
UPDATE
Also consider changing the CardView size to:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Make sure enable hardware Acceleration
You can do it at application level:
<application android:hardwareAccelerated="true" ...>
Or activity level:
<application android:hardwareAccelerated="false">
<activity ... />
<activity android:hardwareAccelerated="true" />
</application>
Or Window level, view level, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With