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 8553927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:45:57+00:00 2026-06-11T14:45:57+00:00

I defined a drawable in xml: <shape xmlns:android=http://schemas.android.com/apk/res/android > <padding android:bottom=1dp android:left=0dp android:right=0dp android:top=5dp

  • 0

I defined a drawable in xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <padding
        android:bottom="1dp"
        android:left="0dp"
        android:right="0dp"
        android:top="5dp" />

    <corners
        android:bottomLeftRadius="0.1dp"
        android:bottomRightRadius="0.1dp"
        android:topLeftRadius="15dp"
        android:topRightRadius="15dp" />

</shape>

And use it in layout xml:

<RelativeLayout
    style="@style/TabHeader"
    android:background="@drawable/_moremsg_tab_back" >

    <TextView
        android:id="@+id/text"
        style="@style/TabText"
        android:text="TODO" />

</RelativeLayout>

The effect is (the first tab):

enter image description here

When click the other tabs, I add the drawable as their background by code:

v.setBackgroundDrawable(getResources().getDrawable(R.drawable._moremsg_tab_back));

But it displays different as the first one:

enter image description here

How to fix it?

  • 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-11T14:45:58+00:00Added an answer on June 11, 2026 at 2:45 pm

    I believe padding is removed when you set a drawable in code.

    I know its not what you want to hear but this is an android bug. There are ways around it, but nothing clean.

    See this question:
    Where'd padding go, when setting background Drawable?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined a rectangle drawable like this: <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <corners android:radius=4dip/> <solid
I've defined a custom shape in my res/drawable folder: <?xml version=1.0 encoding=utf-8?> <shape xmlns:android=http://schemas.android.com/apk/res/android
The following is a dashed line, defined as a ShapeDrawable in XML: <shape xmlns:android=http://schemas.android.com/apk/res/android
I am dynamically inflating following xml <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=wrap_content android:layout_height=wrap_content android:layout_margin=10dip
<?xml version=1.0 encoding=utf-8?> <FrameLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/frameLayout1 android:layout_width=fill_parent android:layout_height=fill_parent android:background=@drawable/background_gradient > <RelativeLayout android:layout_width=fill_parent android:layout_height=fill_parent android:gravity=center
my appwidget is defined with the following widget-provider-info <?xml version=1.0 encoding=utf-8?> <appwidget-provider xmlns:android=http://schemas.android.com/apk/res/android android:configure=de.firepower.andwol.widget.AndWOLWidgetConfigure
I define following drawable my_background_drawable.xml : <?xml version=1.0 encoding=utf-8?> <layer-list xmlns:android=http://schemas.android.com/apk/res/android > <item> <shape
Well' I have a RelativeLayout <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=wrap_content android:clickable=true android:background=@drawable/my_shape_normal android:onClick=startTestTillError> and
My Android app's main activity looks like this: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/RelativeLayout1
I have application A defined as below: <application android:icon=@drawable/icon android:label=@string/app_name> <activity android:name=com.example.MyExampleActivity android:label=@string/app_name> <intent-filter>

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.