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

  • Home
  • SEARCH
  • 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 3983758
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:41:15+00:00 2026-05-20T05:41:15+00:00

I am attempting to create a 3 x 3 grid of items. Each Item

  • 0

I am attempting to create a 3 x 3 grid of items. Each Item consists of an ImageView on top of a TextView. Unfortunately, I am having issues getting everything to play nicely.

Here is my attempt to get 2 such items side by side. The text views don’t even show, and the icons are squished together (instead of evenly spaced)

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1" android:gravity="center"
    android:paddingLeft="40px" android:paddingRight="40px" >
<TableRow>
    <LinearLayout android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
        <ImageView 
           android:id="@+id/usertoolsimage"
           android:src="@drawable/ftnicon"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           />
        <TextView
        android:text="User Accounts"
        android:gravity="right"
        android:padding="3dip" android:textColor="#ffffff" />
    </LinearLayout>


   <LinearLayout android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
        <ImageView 
           android:id="@+id/queueimage"
           android:src="@drawable/ftnicon"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           />
        <TextView
        android:text="Queue Management"
        android:gravity="right"
        android:padding="3dip" android:textColor="#ffffff" />
    </LinearLayout>
</TableRow>

<TableRow>
    <TextView
        android:text="test 3"
        android:padding="3dip" android:textColor="#ffffff" />
    <TextView
        android:text="test 4"
        android:gravity="right"
        android:padding="3dip" android:textColor="#ffffff" />
</TableRow>
</TableLayout>

My goal in the end is to have a grid of clickable items where the item is an image and text for a main menu. Can anyone guide me on what layouts I should use to achieve this?

  • 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-20T05:41:16+00:00Added an answer on May 20, 2026 at 5:41 am

    Your best bet in my opinion would be to use the gridView that way it supports scrolling and spacing and you can be very dynamic in what each items layout and events are. Another option is to just create a lay out the images with a combination of Relative/Linear Layouts.

    GridView layout:

    <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/myGrid"
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:padding="10dp"
    android:verticalSpacing="10dp"
    
    android:horizontalSpacing="10dp"
    android:numColumns="3"
    android:columnWidth="60dp"
    android:stretchMode="columnWidth"
    
    android:gravity="center"
    />
    

    and then in your activity:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        mGame.status = GameStatus.PLAYING;
    
        setContentView(R.layout.gridLayout);
        GridView grid = (GridView) findViewById(R.id.myGrid);
        grid.setAdapter(new customAdapter());
    
        grid.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                //do some stuff here on click
            }
        });
    }
    
    public class customAdapter extends BaseAdapter {
    
        public View getView(int position, View convertView, ViewGroup parent) {
    //create a basic imageview here or inflate a complex layout with
    //getLayoutInflator().inflate(R.layout...)
            ImageView i = new ImageView(this);
    
            i.setImageResource(mFams.get(position).imageId);
            i.setScaleType(ImageView.ScaleType.FIT_CENTER);
            final int w = (int) (36 * getResources().getDisplayMetrics().density + 0.5f);
            i.setLayoutParams(new GridView.LayoutParams(w * 2, w * 2));
            return i;
        }
    
        public final int getCount() {
            return 9;
        }
    
        public final Family getItem(int position) {
            return mFams.get(position);
        }
    
        public final long getItemId(int position) {
            return position;
        }
    }
    

    Or the basic layout using linear layouts:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    
    <LinearLayout android:id="@+id/linearLayout1" 
    android:layout_height="fill_parent" 
    android:layout_weight="1"
    android:layout_alignParentLeft="true" 
    android:layout_width="fill_parent"
    android:orientation="horizontal">
    
        <ImageView>...</ImageView>
        <ImageView>...</ImageView>
        <ImageView>...</ImageView>
    
    </LinearLayout>
    
    <LinearLayout android:id="@+id/linearLayout2" 
    android:layout_height="fill_parent" 
    android:layout_weight="1"
    android:layout_alignParentLeft="true" 
    android:layout_width="fill_parent"
    android:orientation="horizontal">
    
        <ImageView>...</ImageView>
        <ImageView>...</ImageView>
        <ImageView>...</ImageView>
    
    </LinearLayout>
    
    <LinearLayout android:id="@+id/linearLayout3" 
    android:layout_height="fill_parent""
    android:layout_weight="1"
    android:layout_alignParentLeft="true" 
    android:layout_width="fill_parent"
    android:orientation="horizontal">
    
        <ImageView>...</ImageView>
        <ImageView>...</ImageView>
        <ImageView>...</ImageView>
    
    </LinearLayout>
    

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

Sidebar

Related Questions

I'm attempting to create thumbnails out of some images, each of which isn't necessarily
I'm attempting to create a grid style view (similar to NSCollectionView ), except using
I'm attempting to create a grid of availability from a number of tables to
I'm attempting to create a table/grid like view which i can use for displaying
I'm attempting to create a Product Engine for Apostrophe. I'm having trouble extending the
While attempting to create a replacement tablespace for USER, I accidentally created a datafile
Im attempting to create a new operator :? on lists, which operates the same
I attempting to create an 800x500 div with four overlapping divs inside the container
I attempting to create custom tabs using this . But when I try to
I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv

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.