0

I'm using AutoResizeTextView avaiable at this post in stackoverflow.

I have made a grid list with image on top and text on bottom, the way its being done is like this:

<ScrollView>
  <LinearLayout>
    <Programmed LinearLayout HORIZONTAL orientation>
      <Programmed LinearLayout VERTICAL orientation>
        <Programmed ImageView/>
        <Programmed AutoResizeTextView/>
      <LinearLayout/>
      (Repeats till screen width complete)
    <LinearLayout/>
    (Repeats till screen heigth complete)
  <LinearLayout/>
<ScrollView/>

Here is a image of how it looks and the "problem" i'm having: MKX Move List app

As you can see Cassie Cage and Jacqui Briggs has the text autosized to fit in the space reserved for it, the thing is, it seems different fom the rest of the names, and what I want is to get the smallest text and resize all the other ones to that size.

Heres a sketch of the code I started making for it, but its not working.

ArrayList<TextView> TextViewList = new ArrayList<TextView>();
float smallerTextSize=999999f;

  //Declaring one of the textViews:
  AutoResizeTextView tv = new AutoResizeTextView(this);
  //Correction for 4.0.4 android or lower
  final String DOUBLE_BYTE_SPACE = "\u3000";
  String fixString = "";
  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR1
    && android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
    fixString = DOUBLE_BYTE_SPACE;
  }
  tv.setText(fixString + "The text" + fixString);
  tv.setPadding(Math.round(gap / (qtd + 1)), 0, 0, 0);
  tv.setText(name);
  la.addView(tv);
  TextViewList.add(tv);
  if(tv.getTextSize()<smallerTextSize){
    smallerTextSize=tv.getTextSize();
  }

So in this code above I declare one of the TextViews that I use in the screen (any increments suggestions will be appreciated)

final int tvlSize = TextViewList.size();
for(int i=0;i<tvlSize;i++){
  TextViewList.remove(0).setTextSize(smallerTextSize);
}

So I use the smallerTextSize found in the declaration of the textSizes so I can change the textSize of all the TextViews, but it doesn't work, and the result keeps being the same as the image shown.

How can it be done correctly so all the text assume the size of the smallest one so it keeps up a pattern? Also, is there a way for those texts to be aligned in the center of that gap?

Thanks in advance!

Community
  • 1
  • 1

1 Answers1

0

Specify your textsize in sp. It will scale according to the screen size. http://developer.android.com/training/multiscreen/screendensities.html

Use gravity to align the text in the center.

TechnoBlahble
  • 633
  • 5
  • 14