Solved

Need help arranging icons on Main Activity

Posted on 2013-06-18
3
621 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
3 Comments
 
LVL 16

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now