4

I have a situation where I want to add an image view doing the same effect as this app

Screenshot

As you notice there is a drawable or something hiding the bottom side of the view adding a transparent gradient. How can I achieve the same effect?

j2ko
  • 2,330
  • 1
  • 14
  • 27
Mo Dev
  • 395
  • 3
  • 12

3 Answers3

4

Place this drawable in the bottom of your layout:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#FFFFFF"
        android:endColor="@android:color/transparent"
        android:angle="90" />
</shape>

Your layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white" > 
    <View
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@drawable/gradient"
        android:layout_gravity="bottom"/>

</FrameLayout>
Matthew Strukov
  • 321
  • 1
  • 5
2

Well, you can use fadingEdge attribute of the listView in your xml. Make a listView, then add items xml (images in particular as you've mentioned above).

android:fadingEdge="horizontal" android:fadingEdgeLength="30dp" android:fillViewport="false" android:requiresFadingEdge="vertical"

0

I think you can change alpha value of that image View. Go through this and this for more details.