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
Solved

Need help arranging icons on Main Activity

Posted on 2013-06-18
3
655 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb stateless example 2 18
Chrome and Firefox Java 5 50
why no phone sync 11 43
web project error add remove 1 27
Working settings for French ISP Orange "Prêt à Surfer" SIM cards for data connections only. Can't be found anywhere else !
A short article about a problem I had getting the GPS LocationListener working.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

808 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