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 8143089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:00:17+00:00 2026-06-06T13:00:17+00:00

I have a GridView and each cell has an ImageView with TextView under it.

  • 0

I have a GridView and each cell has an ImageView with TextView under it. Unfortunately if the TextView has more than one line the text gets cut off. I have tried everything but I cant find a solution.

It seems that the row height of the GridView is the problem and not the actual text because you can see half of the text in the Textview.

Here is my code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    GridView gridView = (GridView) findViewById(R.id.gridView1);
    gridView.setAdapter(new ImageAdapter());

    gridView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
            startActivity(new Intent(Main.this, Acronyms.class));
        }

    });
}

public class ImageAdapter extends BaseAdapter {

    private Integer[] iconImg = { 
            R.drawable.acronyms, R.drawable.acronyms,
            R.drawable.acronyms
    };
    private String[] iconTitle = {
            "Acronyms", "Cardiac Strips",
            "Test 3"
    };

    public int getCount() {
        return iconImg.length;
    }

    public Object getItem(int arg0) {
        return null;
    }

    public long getItemId(int arg0) {
        return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View view = null;
        if (convertView == null) { 
            LayoutInflater inflater = getLayoutInflater();
            view = inflater.inflate(R.layout.icon, null);
            TextView textView = (TextView) view.findViewById(R.id.icon_text);
            textView.setText(iconTitle[position]);
            ImageView imageView = (ImageView) view.findViewById(R.id.icon_image);
            imageView.setImageResource(iconImg[position]);

        } else {
            view = convertView;
        }

        return view;
    }
}

main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#a3e6ff"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:paddingBottom="10dp"
        android:paddingTop="10dp"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="25"
        android:text="Example"
        android:textColor="#248fb7"
        android:textSize="40dp"
        android:typeface="serif" android:gravity="center_horizontal"/>

    <GridView
        android:id="@+id/gridView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:columnWidth="90dp"
        android:horizontalSpacing="10dp"
        android:numColumns="3"
        android:stretchMode="columnWidth"
        android:verticalSpacing="15dp" >
    </GridView>

</LinearLayout>

and my icon.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/grid_icon_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/icon_image"
        android:layout_width="90dp"
        android:layout_height="wrap_content" />


    <TextView
        android:id="@+id/icon_text"
        android:layout_width="90dp"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:maxLines="2"
        android:singleLine="false"
        android:text="Samples Samples"
        android:textColor="#FFFFFF"
        android:textSize="15dp"
        android:typeface="serif" />

</LinearLayout>

And here is a screenshot:
Multi-line cut off

  • 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-06T13:00:19+00:00Added an answer on June 6, 2026 at 1:00 pm

    [EDIT1]

    You could try using a RelativeLayout instead of a Linear Layout for the icon.xml.

    If this doesnt work then I would then move to a static height TextView. From looking at your screenshot, it looks like you will always use the same image, and the text is either going to be 1 line or 2. Just make the text height static to allow for 2 lines.

    [ORIGINAL]
    I think the problem is in your linear layout definition for your icon.xml. In your definition, you have the layout having “match_parent” as the width and height parameters. You should, since these are to essentially be subviews within the gridview be “wrap_content”. Here is what I think it should be

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     
        android:id="@+id/grid_icon_layout"     
        android:layout_width="wrap_content"     
        android:layout_height="wrap_content"     
        android:gravity="center_horizontal"     
        android:orientation="vertical" >
    
        <ImageView android:id="@+id/icon_image"         
            android:layout_width="90dp"         
            android:layout_height="wrap_content" />       
    
        <TextView android:id="@+id/icon_text"         
            android:layout_width="90dp"         
            android:layout_height="wrap_content"         
            android:gravity="center_horizontal"         
            android:maxLines="2"         
            android:singleLine="false"         
            android:text="Samples Samples"         
            android:textColor="#FFFFFF"         
            android:textSize="15dp"         
            android:typeface="serif" />
    
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Situation: I have several Gridviews on one page, and each Gridview has a dynamically
I have a GridView in which each row has a custom view. The grid
I have a gridview with multiple rows, each has a Update button and I
I have a GridView control that for each item has a Hyperlinkfield with a
I have a GridView that shows a list of users. Each user has a
i have GridView with each Grid as a simple TextView. i need a scrollbar
I have a gridview with some imagebuttons, each of which kicks off a report
I have a gridview that shows an image as part of one of its
I have a gridview that displays items details, I added two template fields one
I have a gridview in which there are two elements in each of its

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.