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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:48:25+00:00 2026-05-21T08:48:25+00:00

i am having a problem with my imagebutton it does not align right when

  • 0

i am having a problem with my imagebutton it does not align right when i specify the centerinparent.

<LinearLayout
        android:layout_width="match_parent" android:layout_marginTop="4dp"
        android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
        android:layout_height="50dp" android:background="#FF0000">

        <RelativeLayout android:layout_height="match_parent"
            android:layout_width="40dp" android:background="#0000FF">
            <ImageView android:id="@+id/imgType"
                android:layout_centerInParent="true" android:layout_width="wrap_content"
                android:src="@drawable/type_text" android:layout_height="wrap_content" />
        </RelativeLayout>

        <RelativeLayout android:layout_height="match_parent"
            android:layout_width="match_parent" android:layout_weight="1">
            <LinearLayout android:orientation="vertical"
                android:layout_height="match_parent" android:layout_width="match_parent">
                <TextView android:layout_width="match_parent"
                    android:textColor="#686a68" android:layout_height="match_parent"
                    android:textSize="15dp" android:text="Manifest : Text"
                    android:ellipsize="end" android:singleLine="true"
                    android:layout_weight="1" />

                <TextView android:layout_width="match_parent"
                    android:textColor="#686a68" android:layout_height="match_parent"
                    android:textSize="15dp" android:id="@+id/txtTitle" android:text="[TEXT NAME]"
                    android:layout_weight="1" android:singleLine="true"
                    android:ellipsize="end" />
            </LinearLayout>
        </RelativeLayout>

        <RelativeLayout android:layout_height="match_parent"
            android:layout_width="60dp" android:background="#00FF00">
            <ImageButton android:src="@drawable/type_text"
                android:layout_height="48dp" android:layout_centerInParent="true"
                android:layout_width="48dp" android:id="@+id/butEdit" />
        </RelativeLayout>

    </LinearLayout>

image

As you can see the vertical alignment of the imagebutton is not right.

why is it doing this.

  • 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-21T08:48:26+00:00Added an answer on May 21, 2026 at 8:48 am

    Have you tried running this on the emulator and using the hierarchyviewer tool (in the “tools” folder of the SDK. Click on your app in the list and select “Load View Hierarchy” ) to inspect the elements in question? Have a look at the margins and padding of both the problem control & its container. Also look at the widths of the various components and it may give you a clue as to where the problem is occurring.

    Also check that your drawable in @drawable/type_text does not contain any space around it which could be causing a perceived offset (unlikely, I think).

    I have occasionally seen odd problems scaling images, so if @drawable/type_text is not 48×48 pixels, try manually scaling the image to the desired size in Photoshop / GIMP / PSP and see if that makes a difference.

    Alternatively try using gravity to try to centre your control:

    <LinearLayout android:layout_height="match_parent" android:gravity="center"
        android:layout_width="60dp" android:background="#00FF00">
        <ImageButton android:src="@drawable/type_text"
            android:layout_height="48dp"
            android:layout_width="48dp" android:id="@+id/butEdit" />
    </LinearLayout>
    

    Or maybe:

    <LinearLayout android:layout_height="match_parent" android:gravity="center"
        android:layout_width="wrap_content" android:background="#00FF00">
        <ImageButton android:src="@drawable/type_text"
            android:layout_height="48dp" android:layout_width="48dp"                               
            android:layout_margin="12dp" android:id="@+id/butEdit" />
    </LinearLayout>
    

    If all else fails, try tweaking the individual android:layout_margin* attributes of the ImageButton to try and force things.

    I hope that some of this helps.

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

Sidebar

Related Questions

Having problem in IE8 with vertical align for images not working when a table
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
fairly new Android developer here. I've come across a strange problem that I'm not
i having problem understanding what is wrong with my inheritance. I just can not
I am having problem with the database access in android. First, I created an
I have searched and not found any clear answers to a problem im having.
I'm having trouble in my Android application. I need add LinearLayouts inside another linearlayout.
I am having problem with download my android application from my own web server.
I am having problem defining CSS rules for browsers that do not support font-stretch
Im having problem in my UIscrollView ,this is what I have done: Whenever a

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.