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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:02:01+00:00 2026-06-16T05:02:01+00:00

I don’t see why I only get 1 column in my grid view no

  • 0

I don’t see why I only get 1 column in my grid view no matter what I do.. frustrating.

activity’s xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent" 
          android:orientation="vertical">

  <GridView
      android:id="@+id/gridView_album"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:numColumns="2"
      android:verticalSpacing="10dp"
      android:horizontalSpacing="10dp"
      android:stretchMode="columnWidth"
      android:gravity="center" />

</LinearLayout>

for each item in the grid view (this is inflated in my adapter)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="vertical" >

  <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginLeft="5dp"
      android:layout_marginRight="5dp"
      android:orientation="vertical" >

    <TextView
        android:id="@+id/textView_albumTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="album title" />

  </LinearLayout>

  <ImageView
      android:id="@+id/imageView1"
      android:layout_width="105dp"
      android:layout_height="100dp"
      android:src="@drawable/abs__ab_share_pack_holo_light" />

  <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="20dp"
        android:layout_height="20dp"
    android:layout_marginLeft="5dp"
    android:layout_marginTop="5dp"      
        android:src="@drawable/abs__ab_solid_light_holo" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="20dp"
        android:layout_height="20dp"
    android:layout_marginLeft="5dp"
    android:layout_marginTop="5dp"      
        android:src="@drawable/abs__ab_solid_light_holo" />

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="20dp"
        android:layout_height="20dp"
    android:layout_marginLeft="5dp"
    android:layout_marginTop="5dp"      
        android:src="@drawable/abs__ab_solid_light_holo" />

    <ImageView
        android:id="@+id/imageView5"
        android:layout_width="20dp"
        android:layout_height="20dp"
    android:layout_marginLeft="5dp"
    android:layout_marginTop="5dp"      
        android:src="@drawable/abs__ab_solid_light_holo" />

  </LinearLayout>

</LinearLayout>

and my adapter’s getView

   @Override
        public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;

        JsonAlbum jsonAlbum = (JsonAlbum) getItem(position);
        ArrayList<JsonAlbumImage> jsonAlbumImageArray = jsonAlbum.album_image_list;

        if (v == null) {
            LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.album_list_row, null);

        }


        TextView textView_albumTitle = (TextView) v.findViewById(R.id.textView_albumTitle);
        textView_albumTitle.setText(jsonAlbum.title);

        ImageView imageView1 = (ImageView)v.findViewById(R.id.imageView1);
        ImageView imageView2 = (ImageView)v.findViewById(R.id.imageView2);
        ImageView imageView3 = (ImageView)v.findViewById(R.id.imageView3);
        ImageView imageView4 = (ImageView)v.findViewById(R.id.imageView4);
        ImageView imageView5 = (ImageView)v.findViewById(R.id.imageView5);

        ArrayList<ImageView> imageViewList = new ArrayList<ImageView>();
        imageViewList.add(imageView1);
        imageViewList.add(imageView2);
        imageViewList.add(imageView3);
        imageViewList.add(imageView4);
        imageViewList.add(imageView5);

        int imageCount = Math.min( imageViewList.size(), jsonAlbumImageArray.size());
        for(int i=0; i < imageCount; ++i)
        {
            ImageView imageView = imageViewList.get(i);
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            JsonAlbumImage jsonAlbumImage = jsonAlbumImageArray.get(i);
            imageLoader.displayImage(jsonAlbumImage.url_image, imageView, options);
        }

        Log.i("debug", "width: "+ Integer.toString(v.getWidth()));
        return v;
    }
  • 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-06-16T05:02:03+00:00Added an answer on June 16, 2026 at 5:02 am

    Hi This is my Gridview code

    <GridView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/gridView1"
        android:numColumns="2"
        android:gravity="center"
        android:columnWidth="100dp"
        android:stretchMode="columnWidth"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    

    My imageview code:

    <ImageView
            android:id="@+id/grid_item_image"
            android:layout_width="150px"
            android:layout_height="150px"
            android:layout_marginRight="50px"
            android:src="@drawable/ic_launcher" >
        </ImageView>
    

    I am getting 2 columns..Lets u try for this attributes..

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

Sidebar

Related Questions

Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't these two mean the same thing, first get the value and then increment?
Don't know a whole lot about streams. Why does the first version work using
Don't ask me how but I managed to get accidentally the following remote branches
Don't get me wrong PDO is great but what I don't like about it,
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Don't get me wrong - I love Smalltalk, but... To me, the Squeak interface
(Don't care about the version. IE or not IE.)
Don't know why I can't reply to people on here with only a small
Don't get me wrong, I want them to get saved. But I always thought

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.