I make a simple list choice multiple selection option, using an array of String. The text of the list item is very long and wrapped into 2-5 lines. The text is not being fit into the list item boundary if it exids more than 2 rows. The boundary of the List item overlapping the text.
Please let me know how to adjust the height of the List item accoding to the lenght of the text.
Thanks
You need to cut off the text if its very long or wrap everything by adjusting the font?
If you need to adjust with the font you may look into the following question, which I faced and the answer is written by me itself in it...
TextView text shrink to the given width
Related
I am trying to achieve something like the picture, I have grouped data , and every group can have 1 or more (different count of items) , most items in the groups share the view type which is simple icon , title, description kind.
But the tricky part is how can I get the header (in landscape mode ) aligned to first item of the group , and allow it to scroll with the list.
One way I could think was let one item in the recycleView be the whole group . i.e header + list items , but that would not give the recycling of the views, defeating whole purpose of reclycleview.
I am looking for some pointers or ideas on how I could approach this.
Note : Header height could be larger that item height and may extend till second item in the group. basically imagine the header to be an Icon and text
I'm implementing a rich text editor. In that, when user clicks on bullet icon in toolbar, an empty bullet should be created with no character in it. But I can not achieve this by setting span on the cursor position. I have to add an unwanted space to do this. Using below code,
editable.insert(cursorPos, " ");
editable.setSpan(new BulletSpan(), cursorPos, cursorPos + 1,Spanned.SPAN_INCLUSIVE_INCLUSIVE);
I have also tried with LeadingMarginSpan but same result. I am getting the required feature, if the cursor is placed in first position of EditText or there is any text in that line. Also same problem persists in Numbered list also.
And the problem persists only for first bullet/Number in list. In subsequent bullet or numbered list item the span is working properly.
Can you please anyone help me how to implement empty bulletspan without any space or character ?
Thanks in advance...
I am setting a text in textview.And it is marquee text.Not just the text, it is an array of text concatenated one after another and added to textview.I want that if i will click any text then that text(or word) will be shown in a dialog box.First of all is it Possible anyhow.I tried to use Spannable from this link first answer.but it's not working as per my requirement as i have marqueeing text.
Why wouldn't you replace the marque with something more useful? :) You may wrap your textView into a horizontal scroll view. Then you have a thread (AsyncTask) that scrolls the text, using ScrollView.setScrollX() just as marquee does.
Can you guess, what comes next? Use spans, as suggested by the link, you quoted!
I have a widget where I need to display some text on one row. If the text does not fit, I would like to show as much as possible and end the text with "..." to show that not all text is displayed. Is there a way to discover how long the displayed text will be before rendering the widget, so that I can replace the last part of the text with "..."?
Cheers,
You don't need to do that - a TextView can do it for you.
myTextView.setSingleLine(true);
myTextView.setEllipsize(TextView.TruncateAt.END);
I want to display the icons in grid view and also text heading for that icon just below it.
can some one help me out.
You are supplying an Adapter to the GridView. Have that Adapter return Views for the cells that have icons "and also text heading for that icon just below it". You might use a vertical LinearLayout with an ImageView and TextView children, for example.
Here is a free excerpt from one of my books that shows how to do this sort of thing for a ListView -- the same technique holds for GridView.
If you are beggining in Android like me, I found out that the simplest thing to start with is to:
1) Set each grid to contain a textview
2) Set background (icons in your case) to each textview; plus add the text.
Like:
//textview is a the textview in the cells
textview.setBackgroundResource(<your icon resource>);
The text is added and modified normally:
textview.setTextColor(Color.BLACK);
textview.setTextAppearance(mContext, R.<style xml>);
textview.setGravity(Gravity.BOTTOM);
You'd most likely need to properly set the text position and color so you have a readable result.
Then you may also set the background properties (you can check textview methods)