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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:28:06+00:00 2026-06-18T07:28:06+00:00

The following code is for displaying a custom button in Android. Unfortunately, all those

  • 0

The following code is for displaying a custom button in Android. Unfortunately, all those padding values at those different places affect the way the button is rendered only for Android 2.3, but on Android 4.X it has no effect, i.e. the padding is always the same, regardless of what you set here. Why?

The layout XML:

<Button
    android:id="@+id/sample_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_caption"
    android:padding="6dp"
    android:layout_marginBottom="6dp"
    android:layout_marginRight="6dp"
    style="@style/CustomButton"
    android:textSize="16sp" />

The style:

<style name="CustomButton">
    <item name="android:layout_gravity">center_horizontal</item>
    <item name="android:padding">6dp</item>
    <item name="android:background">@drawable/custom_button</item>
    <item name="android:textColor">#ffffff</item>
    <item name="android:gravity">center</item>
    <item name="android:textStyle">bold</item>
</style>

The drawable:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <shape>
            <solid
                android:color="#60ff0000" />
            <stroke
                android:width="1dp"
                android:color="#ffffff" />
            <corners
                android:radius="4dp" />
            <padding
                android:left="6dp"
                android:top="6dp"
                android:right="6dp"
                android:bottom="6dp" />
        </shape>
    </item>
    <item>
        <shape>
            <solid
                android:color="#90ff0000" />
            <stroke
                android:width="1dp"
                android:color="#ffffff" />
            <corners
                android:radius="4dp" />
            <padding
                android:left="6dp"
                android:top="6dp"
                android:right="6dp"
                android:bottom="6dp" />
        </shape>
    </item>
</selector>

When I set all these padding values to a small value such as 2, the button is shown almost without a padding on Android 2.3.3 (probably correct) but with a padding that is still very large on Android 4.X (probably wrong). Can someone see why?

  • 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-18T07:28:07+00:00Added an answer on June 18, 2026 at 7:28 am

    Android’s Holo theme sets a minWidth and minHeight in the system styles.xml resource for Holo.Widget.Button which specifies rules in addition to those used by the non-holo button, Widget.Button. Even with a small button title, the button will take up 64x48dip in Android 4.2.

    <Button
        android:id="@+id/sample_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Z"
        android:padding="6dp"
        android:minHeight="1dp"
        android:minWidth="1dp"
        android:layout_marginBottom="6dp"
        android:layout_marginRight="6dp"
        style="@style/CustomButton"
        android:textSize="16sp" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written the following code for displaying local notifications.However,a button is not showing
I tried the following code, in an attempt to get the custom view displaying
I am using the following code to click a button for displaying another form
The following code is suppose to be doing this : - Displaying a string
I have the following bit of code which is responsible for displaying a tooltip.
i'm using following code for displaying image inside gridview <asp:TemplateField HeaderText=Contact HeaderStyle-HorizontalAlign=left ItemStyle-HorizontalAlign=left >
I devised the following code for displaying a control's Tag property on mouseover. The
I tried the following code for displaying a number's binary equivalent but i am
The following jQuery autocomplete code is not displaying the results in MVC3. When I
The following code is displaying INF as the result. How can I fix it?

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.