Reputation: 658
In my application I am loading some text from database into a TextView
. Is there any way to detect(set a flag) when the TextView
is fully filled with text.
TextView
has attributes
layout_width = "fill_parent"
layout_height ="fill_parent"
I was searching for a solution and found none. Can someone suggest me a logic.
Upvotes: 1
Views: 616
Reputation: 3266
As your goal is to present text in a ViewPager
I would recommend you rethink your design.
The problem with your approach is that you can never be sure what screen resolution people will have when opening the application or if they want to zoom. If you implement what you want to implement then you either need to reduce functionality so users cannot zoom or change the layout. This is a bad practice in my opinion. In fact, I believe the Android Developers Design Principles might even have to say something about that. I would recommend you always offer functionality with your application that the users are likely to expect.
Should you still want to go ahead you need to consider that when users zoom, the amount of text the screen is able to display will change. Not only will this lead to quite some computation overhead as a zoom is likely a continuous event, but it will also mean that the users might see some jerking around of text. Again, unexpected behaviour.
What I would recommend is that you either compute the amount of text you want to display beforehand for the given display and then stick with it, leaving people free to zoom at their leisure, or you issue an Intent
(Documentation) to an application that implements the desired behaviour.
Upvotes: 1
Reputation: 1686
Try to calculate the TextView width and the actual text width and compare. You can calculate the actual text width by this function:
Paint p = new Paint();
float text_width = p.measureText("your_text");
Hope this helps.
Upvotes: 1
Reputation: 3431
TextView
by default I believe has overflow set. You need to set restrictions. Do something like: android:maxLength="20"
then create a statement to see if the size of the TextView
is 20
Upvotes: 0