Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6840433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:50:37+00:00 2026-05-26T23:50:37+00:00

How can I position a radial gradient shape as background in a LinearLayout ?

  • 0

How can I position a radial gradient shape as background in a LinearLayout ? Here is what I presently have :

The shape :

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:endColor="#e6e6e6"
        android:gradientRadius="800"
        android:startColor="#fafaf9"
        android:type="radial"/>
</shape>

The LinearLayout :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:background="@drawable/accueil_bg_gradient">
</LinearLayout>

I just want to have my gradient starting from the left upper corner of the screen, and ending at the right lower corner.

Thanks a lot !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:50:37+00:00Added an answer on May 26, 2026 at 11:50 pm

    You can move the middle of the radial gradient at a different position of the drawable using “centerX” and “centerY” attributes of the gradient. They are a floating point values ranging from 0 to 1.0 where (values of centerX,centerY accordingly) 0,0 is upper left and 1,1 is bottom right corner.

    Default is 0.5,0.5 which is the middle of the drawable / assigned space.
    Example for a 100px long (radius), black-white gradient whose middle starts at upper left corner would be:

        <shape android:shape="rectangle">
            <gradient
                android:type="radial"
                android:startColor="#ffffff"
                android:endColor="#000000"
                android:gradientRadius="100"
                android:angle="270"
                android:centerX="0"
                android:centerY="0"/>
    
        </shape>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The background-position property can be set in a variety of ways such as top
I can position a small background-image/icon 4 pixels from the center left of its
I can position a background image using the background property in an input field
How can I position the caret in CKEditor3.x? I have 2 positions and I
I have a table of positions where a position can have a related position
I have a TextView . How can I position it by using x and
I toying with a project where I can position objects runtime on the screen.
I need a type which can contain a position of an object in a
To access the array indice at the xth position we can use some sort
Can I apply both position: relative and float: left on one element? Like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.