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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:00:47+00:00 2026-06-13T10:00:47+00:00

I have a ListView with an ArrayAdapter which uses an XML layout, similar to

  • 0

I have a ListView with an ArrayAdapter which uses an XML layout, similar to simple_list_item_1, to inflate its content. I have two options in the app menu to increase/decrease the text size. I managed to modify the text size of the TextViews inside the ListView by overriding the getView function of the ArrayAdapter. Something like this:

adapter = new ArrayAdapter<Line>(MyActivity.this, R.layout.line_list, lines){
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView textView = (TextView) super.getView(position, convertView, parent);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSizeDp + zoom);
        return textView;
    }
};
listView.setAdapter(adapter);

The menu options change the zoom value and call adapter.notifyDataSetChanged(); to make the adapter change the text size.
Until that point everything works.

The problem is that when I decrease the text size too much, the height of each TextView is not wrapping its content. That is, the ListView items are too high. When I increase the text size I don’t have problems with the items height.

If I call super.getView(position, convertView, parent); with convertView being null, I make the adapter to allways inflate. In that case, decreasing the text size works fine since the height is wrapped. However, I’m causing an overload of work and I don’t want that.

I tried invalidating or forcing layout to the listview and/or the textviews but it didn’t work.

Any help is appreciated

EDIT: This is line_list layout:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/lineTextSize"
android:gravity="center"
android:paddingLeft="6dip"
android:paddingRight="6dip" />

lineTextSize is 22dp for default and 40dp for large

EDIT 2: Look like this enter image description here

instead of this screen: enter image description here

  • 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-13T10:00:48+00:00Added an answer on June 13, 2026 at 10:00 am

    I found here that this is a known bug for Android 3.1+

    The solution is to add a string like this

    String ZERO_WIDTH_SPACE = "\u200b";
    

    to the text of the TextViews. So, the correct getView function of the adapter is:

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView textView = (TextView) super.getView(position, convertView, parent);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSizeDp + zoom);
        textView.setText(textView.getText() + ZERO_WIDTH_SPACE);
        return textView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic ListView which uses an ArrayAdapter . When a name is
I have a custom ListView that uses a custom ArrayAdapter (which basically just overrides
I have a listview which is simply populated this way: setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, aux))
I have a ListView that has a custom ArrayAdapter with a custom XML row.
I have ListView that uses a GridView to display several columns of data. Two
In my application, I have ListView which is set by my CustomAdapter (i.e. ArrayAdapter).
I have a custom dialog which extends Dialog and has a ListView inside its
I have a ListView which contains an ImageView and a TextView. I'm subclassing ArrayAdapter
I have a ListView, which is backed by an ArrayAdapter. They are defined as
I have an ArrayAdapter which is hooked up to my ListView . I really

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.