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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:02:00+00:00 2026-06-04T17:02:00+00:00

I am trying to create a layout (using eclipse) in which I need to

  • 0

I am trying to create a layout (using eclipse) in which I need to vertically align various controls like TextView and Button. I am trying to keep all the widgets perfectly left aligned. Even if I specify the same left margins/paddings for the controls, still a difference of 1-2 pixels can be seen between different types of controls.

The problem is that the distance between widget’s border (blue rectangle in eclipse) and widget’s content/graphics varies across widgets (say TextView and Button).

I can apply workarounds by either specifying left padding for TextView or by reducing the left margin of the button container. But I am looking for cleaner solution. I am unable to find any attribute which controls the difference between widget’s border and content.
Any pointers on how I can control this gap ?

Snapshot demonstrating the problem is below. Here is the layout XML that I am using for this problem:-

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Dummy Button" />

</LinearLayout>

The images below show the snapshot of the dummy application. Please note the difference between left side margin of “Hello World” TextView and “Dummy Button”.

The second pic shows the button widget when selected in Eclipse. The blue rectangle indicates the widget boundary/border. Is the difference between button’s border (blue rectangle) and content (greyed rectangle) controllable by some property ?

Dummy Application Snapshot
Button with boundary

  • 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-04T17:02:06+00:00Added an answer on June 4, 2026 at 5:02 pm

    This is a tough one the TextView and other Android widgets may have some intrinsic styles of their own (android version dependant as well).

    Therefore to get around this you would have to create your own style.

    In creating your own style always reference the android source code on this subject:

    https://github.com/android/platform_frameworks_base/tree/master/core/res/res/values

    https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml

    https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml

    There are multiple ways to create your own style.

    One way is to theme your activity in your manifest.
    First you need a styles.xml file, in your /values/ folder.
    In here you would declare your new style:

    <style name="Theme.MyTheme.Dark" parent="@android:style/Theme.NoTitleBar">
        <item name="android:textViewStyle">@style/Widget.TextView.Black</item>
    </style>
    
    <style name="Theme.MyTheme.Light" parent="@android:style/Theme.NoTitleBar">
        <item name="android:textViewStyle">@style/Widget.TextView.White</item>
    </style>
    

    The style above it inheriting from the Android style that hides the title bar, you can inherit from something else.
    In this theme we then override the textViewStyle, this allows us to set custom values for our TextView‘s and override some of the intrinsic values.

    <style name="Widget.TextView.White" parent="@android:style/Widget.TextView">
        <item name="android:textColor">#FFFFFF</item>
    </style>
    
    <style name="Widget.TextView.Black" parent="@android:style/Widget.TextView">
        <item name="android:textColor">#000000</item>
    </style>
    

    Finally you theme your activity in the AndroidManifest.xml:

         <activity
            android:name=".ui.phone.FirstActivity"
            android:theme="@style/Theme.MyTheme.Dark" />
    
         <activity
            android:name=".ui.phone.SecondActivity"
            android:theme="@style/Theme.MyTheme.Light" />
    

    Now when you use a TextView in the FirstActivity it’s text will be Black by default and in the second activity it will be white.

    For your specific question:

    You would have to go look in the source code files I linked at the top and see if there is any padding or minWidth or size attributes that are affecting your widgets and your layout.

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

Sidebar

Related Questions

Im trying to create a layout in flex using mxml, the layout contains a
i'm trying to create following layout: http://jsfiddle.net/BTuMH/1/ but without setting the width, like: http://jsfiddle.net/yuGyg/
I'm trying to create a Tkinter layout that has labels and entry fields vertically
I'm trying to use twitter bootstrap to create Facebook like tooltip layout. I would
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I'm using eclipse + android SDK. I'm trying to create a table with data
Hi im trying to create a simple android app using the Eclipse IDE, all
I am trying to create a layout that will looking like: +---+--------+---+ | |
I'm trying to create a scrollable layout in Android. Even using developers.android.com, though, I
I am trying to create a UI using relative layout where in the UI

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.