Solved

Need help arranging icons on Main Activity

Posted on 2013-06-18
3
672 Views
Last Modified: 2013-06-20
Hello Experts,

My main activity has 4 icons and I'd like to have them organized.  Currently, they are not per my screenshots.  Any help to accomplish the layout on the right side in the attached file would be very much appreciated.

Here is my code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:baselineAligned="_baseline"
    android:focusable="true"
    android:orientation="horizontal"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Main" >

    <ImageButton
        android:id="@+id/news"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="28dp"
        android:layout_marginTop="56dp"
        android:background="@drawable/news"
        android:contentDescription="@string/Contact"
        android:src="@drawable/news" />

    <ImageButton
        android:id="@+id/contact"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="18dp"
        android:background="@drawable/contact"
        android:contentDescription="@string/News"
        android:src="@drawable/contact" />

    <ImageButton
        android:id="@+id/locations"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/locations"
        android:contentDescription="@string/Parks"
        android:src="@drawable/locations" />

    <ImageButton
        android:id="@+id/schedules"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/schedules"
        android:contentDescription="@string/schedules" />

</LinearLayout>

Open in new window

Arranging-Icons-on-Main.png
0
Comment
Question by:Modifier1000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Expert Comment

by:Chris Harte
ID: 39261060
I do not know a lot about layouts, but what I think you need is the onMeasure() method

http://developer.android.com/guide/topics/ui/custom-components.html

Googleling square layout produces a lot of answers, a lot of whom seem to think gridview is the way to go

http://stackoverflow.com/questions/6557516/making-grid-view-items-square

where as others go with table

http://stackoverflow.com/questions/12555106/android-layout-with-4-squares-and-a-button-inside-each-square
0
 
LVL 13

Accepted Solution

by:
Molnar István earned 500 total points
ID: 39263289
0
 

Author Closing Comment

by:Modifier1000
ID: 39264879
Yep, I changed to Relative and got what I wanted...thank you.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Clear Android 2.3.6 Internet Space Used 66 163
Which Oppo n Samsung models are 64bit 6 53
Droid 5 4 12
Overriding a method 3 11
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
A short article about a problem I had getting the GPS LocationListener working.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question