0

I have a very large string that wont fit in the screen if I shown it as a TextView. Could any one tell me how to select a sub string which exactly fit the screen Height and Width independently of the text size of TextView.

1 Answer 1

0

add these attribute to your TextView in the xml

   android:singleLine="true"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
6
  • Hi Javanator, you misunderstood my question, I am not looking for a single line TextView, I want a TestView that fits the entire screen. I am looking for the exact number of characters for that. Feb 10, 2011 at 4:10
  • If view is larger then the screen size and text size is not be compromized then put the textview in a scroll view with fill_parent height and width Feb 10, 2011 at 4:34
  • Hi Javanator, thank you for your comment. I am trying to develop an epub reader. I want to show the TextView in two pages if the text not fit in the current screen. For that I need the exact number of characters that fits the screen. Feb 11, 2011 at 4:12
  • This totaly depends over the text font size. you calculate the the toatl width of avialable screen Using Display and WindowManager classes and then calculate the number of character that will fit into one line, and thus similarly calculate the number of lines in the screen.. Feb 11, 2011 at 4:19
  • Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); Feb 11, 2011 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.