Skip to content Skip to sidebar Skip to footer

Make Complex View "gradiently" Transparent

How to make complex view (which has its own background, imageview and textview inside it) gradiently transparent? For example, first half of this view has normal colors, but the se

Solution 1:

Use RelativeLayout

The complex setup:

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="@dimen/number_picker_row_height"android:background="@android:color/white"><TextViewandroid:id="@+id/textView"android:layout_width="match_parent"android:layout_height="match_parent"/><Viewandroid:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/gradient_bg"/><Viewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:background="@drawable/image" /></RelativeLayout>

in gradient_bg:

<?xml version="1.0" encoding="utf-8"?><shapexmlns:android="http://schemas.android.com/apk/res/android"><gradientandroid:startColor="#55ffffff"android:centerColor="#00ffffff"android:endColor="#ffffffff"android:angle="0"android:dither="true"
        /></shape>

This will achieve an gradient effect on top of whatever TextView, and you can also set whatever background on the RelativeLayout and also add any image view on top of the gradient background.

Hope it helps!

Post a Comment for "Make Complex View "gradiently" Transparent"