Solved

Need help arranging icons on Main Activity

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

729 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