Monday, December 2, 2019

How to gradient linearlayout in android

How to gradient linearlayout in android

Step 1:  create file drawble/gradient.xml
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#000000"
        android:centerColor="#5b5b5b"
        android:endColor="#000000"
        android:angle="0" />
</shape>
Step : Create a layout activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@drawable/gradient_rl_custom"
    android:layout_height="match_parent">
    <RelativeLayout
        android:id="@+id/rl_header_home"
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <TextView
            android:layout_width="wrap_content"
            android:layout_centerInParent="true"
            android:text="Nature Wallpaper"
            android:textSize="30dp"
            android:layout_height="wrap_content" />
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_centerInParent="true"
        android:layout_height="wrap_content">
        <RelativeLayout
            android:id="@+id/rl_wallpaper_home"
            android:layout_width="wrap_content"
            android:layout_margin="20dp"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="wrap_content"
                android:src="@drawable/ic_launcher_background"
                android:layout_height="wrap_content" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/rl_download_home"
            android:layout_width="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_margin="20dp"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="wrap_content"
                android:src="@drawable/ic_launcher_background"
                android:layout_height="wrap_content" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/rl_setting_home"
            android:layout_width="wrap_content"
            android:layout_below="@+id/rl_download_home"
            android:layout_centerHorizontal="true"
            android:layout_margin="20dp"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="wrap_content"
                android:src="@drawable/ic_launcher_background"
                android:layout_height="wrap_content" />
        </RelativeLayout>
    </RelativeLayout>
</RelativeLayout>
out :
How to gradient linearlayout in android

No comments:

Post a Comment