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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:55:19+00:00 2026-05-23T09:55:19+00:00

I’m having a hard time aligning up my image buttons properly during a android

  • 0

I’m having a hard time aligning up my image buttons properly during a android activity. As you can see all the images are all shifted and not aligned properly. And that was after a long time of adjustments.

My main XML layout:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_height="wrap_content" 
     android:adjustViewBounds="true"
    android:layout_weight="1"
        android:gravity="left" 
        android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginBottom="0dp"   
    android:layout_width="fill_parent" android:baselineAligned="true">
 <LinearLayout 
    android:orientation="horizontal"
    android:layout_height="158px" 
      android:adjustViewBounds="false"
    android:layout_weight="1"
        android:gravity="left" 
        android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginBottom="0dp"  
    android:layout_width="fill_parent" android:baselineAligned="true">  

    <ImageButton         
    android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginBottom="0dp"

        android:gravity="left" 
   android:adjustViewBounds="false"
  android:scaleType="fitStart"

        android:layout_gravity="left"
        android:background="@drawable/topfula_r1_c1" 
        android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:id="@+id/fluprepare"
       android:layout_weight="1"
       >

       </ImageButton>
    <ImageButton android:scaleType="fitCenter"        
    android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
   android:adjustViewBounds="false"
    android:layout_weight="1"
        android:layout_marginRight="0dp"
        android:layout_marginBottom="0dp"
        android:gravity="left" 
        android:layout_gravity="left" android:background="@drawable/topfula_r1_c2" 
        android:layout_width="wrap_content" android:layout_height="wrap_content" 
        android:id="@+id/refreshflu" ></ImageButton>
    <ImageButton android:scaleType="fitEnd"        
    android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginRight="0dp"
         android:adjustViewBounds="false"
          android:layout_weight="1"
        android:layout_marginBottom="0dp"
        android:gravity="left" 
        android:layout_gravity="left" 
        android:background="@drawable/topfula_r1_c3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/quitprogram" ></ImageButton>

</LinearLayout>   
 <LinearLayout 
    android:orientation="horizontal"
    android:layout_height="159px" 
      android:adjustViewBounds="true"
    android:layout_weight="1"
        android:gravity="left" 
        android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginBottom="0dp"  
    android:layout_width="fill_parent" android:baselineAligned="true">  

    <ImageButton         
    android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginBottom="0dp"

        android:gravity="left" 
   android:adjustViewBounds="false"
  android:scaleType="fitStart"

        android:layout_gravity="left"
        android:background="@drawable/mid_r1_c1" 
        android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:id="@+id/prepareflu"
       android:layout_weight="1"
       >

       </ImageButton>
    <ImageButton android:scaleType="fitCenter"        
    android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
   android:adjustViewBounds="false"
    android:layout_weight="1"
        android:layout_marginRight="0dp"
        android:layout_marginBottom="0dp"
        android:gravity="left" 
        android:layout_gravity="left" android:background="@drawable/mid_r1_c2" 
        android:layout_width="wrap_content" android:layout_height="wrap_content" 
        android:id="@+id/maincdc" ></ImageButton>
    <ImageButton android:scaleType="fitEnd"        
    android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginRight="0dp"
         android:adjustViewBounds="false"
          android:layout_weight="1"
        android:layout_marginBottom="0dp"
        android:gravity="left" 
        android:layout_gravity="left" 
        android:background="@drawable/mid_r1_c3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/configsettings" ></ImageButton>

</LinearLayout>   


<LinearLayout 
    android:layout_height="460px" 


   android:adjustViewBounds="false"
    android:layout_weight="1"
        android:gravity="left" 
        android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginBottom="0dp"
    android:layout_width="fill_parent" android:orientation="horizontal" android:baselineAligned="true">

<ImageButton android:id="@+id/informationcards" 
android:background="@drawable/bottommain" 
android:layout_gravity="center" android:layout_width="wrap_content" 
android:layout_height="wrap_content" android:layout_weight="1"></ImageButton>
</LinearLayout>
</LinearLayout>

Device Screen shot of layout not aligning

As you can see there is a issue big time with the imagebuttons that I have initialy laid out as a test. Using 1 large bottom image that pushes up 3 images in the top and middle rows that need to be aligned is difficult.

If any more detail is needed, please let me know.

[edit]

android:baselineAligned=”true”
android:layout_weight=”1″
android:baselineAligned=”true”

are just a nightmare to just have right. it is like black magic to get it all perfect with multiple images and layouts that all have to be edge to edge…

I would love to instead of having the 3 layouts all in one larger Layout container seems awful.. a nice sweet grid with edge to edge?

Original not Spliced up

Spliced and ImageButton'd up awww

Whoo hoo! I solved it with lots of trial and error! with 100x less code. like wow.

  • 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-23T09:55:20+00:00Added an answer on May 23, 2026 at 9:55 am

    a snippet from my main.xml file that I used in the above question…

    you will see that it was not done with image buttons. and the beauty of it all is that there is zero chance of image miss alignments. as you will notice the

       android:background="@drawable/mainlayoutbg2"
    

    is one file.. not a whole bunch of pieced up images that you pray will all block together with all there weights and alignments…

    <TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/mainlayoutbg2"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:clickable="true">
    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:height="100px">
        <Button
            android:clickable="true"
            android:height="100px"
            android:layout_width="wrap_content"
            android:id="@+id/Button02"
            android:layout_height="wrap_content"
            android:background="@null"
            android:text="     "
            android:width="100px"></Button>
    
        <Button
            android:clickable="true"
            android:height="100px"
            android:layout_width="wrap_content"
            android:id="@+id/refreshflud"
            android:onClick="refreshflu()"
            android:layout_height="wrap_content"
            android:background="@null"
            android:text="     "
            android:width="100px"></Button>
    
        <Button
            android:clickable="true"
            android:height="100px"
            android:layout_width="wrap_content"
            android:id="@+id/refreshflub"
            android:layout_height="wrap_content"
            android:background="@null"
            android:text="     "
            android:width="100px"></Button>
        <Button
            android:clickable="true"
            android:height="100px"
            android:layout_width="wrap_content"
            android:id="@+id/refreshfluc"
            android:layout_height="wrap_content"
            android:background="@null"
            android:text="     "
            android:width="100px"></Button>
        <Button
            android:height="100px"
            android:text="     "
            android:background="@null"
            android:width="100px"
            android:id="@+id/quitprogram"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"></Button>
    
    </TableRow>
    

    I hope this shaves off some hours from someone elses dev sessions.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.