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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:23:59+00:00 2026-05-26T13:23:59+00:00

I need a certain layout for an android app. I have the custom buttons

  • 0

I need a certain layout for an android app. I have the custom buttons and am able to load them in to a button but need help on how to lay them out on the screen. I am a newbie to android development (See my screen name). Trying to learn how to use .xml

I have attached what I need and what xml code I already have. Any help would be greatly appreciated.

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

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


              <LinearLayout 
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent" 
              android:orientation="horizontal" android:weightSum="1"
              android:gravity="center_vertical|center_horizontal" >
                  <Button android:gravity="center_vertical|center_horizontal" android:id="@+id/button" android:layout_height="wrap_content" android:padding="10dp" android:background="@drawable/schedule_button" android:layout_width="wrap_content"></Button>
                    <Button android:id="@+id/button" android:layout_height="wrap_content" android:padding="10dp" android:background="@drawable/grad_button" android:layout_width="wrap_content"></Button>
              </LinearLayout>


              <LinearLayout 
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent" 
              android:orientation="horizontal" android:weightSum="1"
              android:gravity="center_vertical|center_horizontal" >
                 <Button android:gravity="center_vertical|center_horizontal" android:id="@+id/button" android:layout_height="wrap_content" android:padding="10dp" android:background="@drawable/schedule_button" android:layout_width="wrap_content"></Button>
                <Button android:id="@+id/button" android:layout_height="wrap_content" android:padding="10dp" android:background="@drawable/grad_button" android:layout_width="wrap_content"></Button>
              </LinearLayout>



</LinearLayout>

Her is the layout

  • 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-26T13:23:59+00:00Added an answer on May 26, 2026 at 1:23 pm

    I see that you are trying to display images as buttons. Hence, I would recommend that you use ImageButton instead of a Button. I have included some code. There are a few different ways you can go about trying to achieve what you intend to here. But, I have to chosen to solely use LinearLayout just to keep it simple. Deepa has used a RelativeLayout to achieve this and it is a very good solution indeed. You should look into RelativeLayout as it might help you in the future while structuring layouts.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <ImageButton
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src = "@drawable/ic_launcher"
            android:background="@null"/>
        <ImageButton
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src = "@drawable/ic_launcher"
            android:background="@null"/>
    </LinearLayout>
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >    
        <ImageButton
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:src = "@drawable/ic_launcher"
            android:background="@null"
            android:layout_height="wrap_content"/>
    
        <ImageButton
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:src = "@drawable/ic_launcher"
            android:background="@null"
            android:layout_height="wrap_content"/>
    </LinearLayout>
    
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >    
    
        <ImageButton
            android:id="@+id/button5"
            android:layout_width="wrap_content"
            android:src = "@drawable/ic_launcher"
            android:layout_height="wrap_content"
            android:background="@null"/>
    
        <ImageButton
            android:id="@+id/button6"
            android:layout_width="wrap_content"
            android:src = "@drawable/ic_launcher"
            android:layout_height="wrap_content"
            android:background="@null"/>
     </LinearLayout>   
    

    In the above code I have used the default launch icons as the images. You must replace them as necessary with you corresponding button images. Also, there are 4 important aspects here that you must understand.

    First – I have used android:background=”@null” to get rid of a frame that is attached to the ImageButton. Try to run the code without this line and you will understand what I am talking about

    Second – This line: android:src = “@drawable/ic_launcher” is used to declare the image that you display as the image.

    Third – If you want some space between the buttons you could put in some padding between each of these elements. You could do so by using the ‘android:padding= xxdp’

    Fourth – If you want the buttons to have a specific size, you could do so by replacing the values ‘wrap_content’ by ‘xxdp’ for the width and height. However, it is important that you add the following line when you intend to do so: android:scaleType = “fitXY”. This will tell the element that you want it to be laid out in an absolute manner. But, instead of resorting to this approach, I recommend that you resize the images appropriately before getting them into your layout.

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

Sidebar

Related Questions

I need certain scripts to refire after an AJAX load. How could I accomplish
I have a number of view specs that need certain methods to be stubbed.
I have a ParameterInfo array. I need to remove certain values from the array.
I have been developing an Android app and testing with a 1.5 AVD and
I have a layout where the container holds a sidebar. I need the sidebar
I have a layout where images float within a certain area. The layout looks
In my rails app, I want to render certain pages within a lightbox but
I need a certain part of current URL. Say for example the URL is:
I need send certain attributes(say, human readable user name) from server to client after
My current thinking: I need a certain module that will let me access the

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.