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

  • Home
  • SEARCH
  • 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 8724631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:52:15+00:00 2026-06-13T07:52:15+00:00

I have next XML drawable blue_button <?xml version=1.0 encoding=utf-8?> <selector xmlns:android=http://schemas.android.com/apk/res/android> <item> <layer-list> <item><bitmap

  • 0

I have next XML drawable blue_button

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <layer-list>
      <item><bitmap android:src="@drawable/button_blue_bg" />
      </item>
      <item >
         <shape>
                <corners android:radius="50dip" />
                <stroke android:width="1dip" android:color="#ccffffff" />
                <solid android:color="#00000000" />
                <padding android:bottom="3dip" 
                         android:left="3dip"
                         android:right="3dip"
                         android:top="3dip" />
         </shape>
       </item>
     </layer-list>
  </item>
</selector>

And i have image button_blue_bg with gradient with 1px width.

When i set button background i get next image

enter image description here

As you can see i have background not clipped with rounded border.

How i need modificate xml for background gradient image be not outside border?

I understand why it happended, because i use layers – so this like sandwich- but i also programming on objective c, and there it’s also use layers. But in Apple it’s wotks fine.

  • 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-06-13T07:52:16+00:00Added an answer on June 13, 2026 at 7:52 am

    i use this…. First a Layer for the basic definition, set this layer as backgound of your layout:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
      <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
            <stroke android:width="0.2dp" android:color="@color/anycolor" />
            <corners android:radius="10dp" > </corners> 
        </shape>
      </item>
      <item>
          <bitmap android:src="@drawable/imgback" />
      </item>
     </layer-list>
    

    i use this function for making round corners:

        public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
    
            Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
                bitmap.getHeight(), Config.ARGB_8888);
            Canvas canvas = new Canvas(output);
    
            final int color = 0xff424242;
            final Paint paint = new Paint();
            final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
            final RectF rectF = new RectF(rect);
            final float roundPx = 12;
    
            paint.setAntiAlias(true);
            canvas.drawARGB(0, 0, 0, 0);
            paint.setColor(color);
            canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    
            paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
            canvas.drawBitmap(bitmap, rect, rect, paint);
    
            return output ;
          }     
    

    and finaly, the code in the activity:

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        // i use a Relative Layout  
        RelativeLayout rl = (RelativeLayout) findViewById(R.id.rlmenu);
        // Obtain then backgroud of RelativeLayout
        LayerDrawable layer = (LayerDrawable) rl.getBackground();
        // obtain the image set in the Layer
        BitmapDrawable bg = (BitmapDrawable) layer.getDrawable(1);
        // create a new BitmapDrawable from the function
        Drawable d =new BitmapDrawable(getRoundedCornerBitmap(bg.getBitmap()));
        // set the new roundcorner image in the layer
        layer.setDrawableByLayerId(1, d);
        rl.setBackgroundDrawable(d);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have following layout: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/editorRootView android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical > <RelativeLayout android:id=RL1
I have the next element <statement id =5> insert into TBTEMPLATES(CTDB_LAST_UPDATOR) values('<?xml version=1.0 encoding=UTF-8?><Interface
I have created a custom Button as follows. file : buttoncontrol.xml <?xml version=1.0 encoding=utf-8?>
I have the next code to retrieve some data from a xml file. The
I have next xml: <page> <document> <id>1001</id> <cur>USD</cur> <date>01.01.2009</date> <amount>10</amount> </document> <document> <id>1001</id> <cur>USD</cur>
Picture of the android interface: http://tinypic.com/view.php?pic=avht6w&s=6 As seen in the picture above I want
I have recently started programming android apps (put simply, i have next to no
Have an XML with next form: <categories someAttribute=test> <category id=1> <title></title> </category> <category id=1>
${HBASE_HOME}/conf/hbase-site.xml have next values: <property> <name>hbase.zookeeper.quorum</name> <value>hd1</value> </property> hd1 hostname is setup in /etc/hosts,
I have next code, <form id=form1 runat=server> <asp:Label runat=server ID=Label1 EnableViewState=false /> <asp:CheckBox runat=server

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.