Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make Radial Gradient in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.71k
    Comment on it

    Using below Layout code you can create a Radial Gradient, Here I have created a Gradient.xml layout by using shape and gradient property. By using GradientDrawer we can make smooth transition between two or three colors in liner, radial or sweep pattern. The below exampel layout will clearly describe you to make Radial Gradient.

    Step(1)-MainActivity-

    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
    }
    

    Step(2)-Actvity_Main layout-

    <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="@string/hello_world"
            android:background="@drawable/gradient"
             />
    
    </RelativeLayout>
    

    Step(3)- Create Gradient.xml layout

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval"
        android:useLevel="false" >
    
        <gradient
            android:centerColor="#000000"
            android:endColor="#ffffff"
            android:gradientRadius="300"
            android:startColor="#ffffff"
            android:type="radial"
            android:useLevel="false" />
    
    </shape>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: