I have several textviews in my application, sometimes it looks messing, like below:
In normal case, it shoule be like this:
Anyone met this before? Thanks:)
Seemed the customized ROM made some changes to the framework, and the textview buffer is not well cleared before set the new text.
I solve this by setting empty text before setting the real text.
By the way, why my post got the minus point....
Related
I have a brain picking problem that I am trying to solve for smart wrapping for TextView in Android. I have a LinearLayout (horizontal) that consists of TextView1, TextView2 and an ImageView. TextView1 can have long text or short text. For short text everything looks pretty neat and as expected. Like this -
Now the problem occurs when the text in TextView1 gets longer. Since maxLines for TextView1 is 2, it looks something like this
This is not an ideal experience because at many occasions there is a lot of white space text just lingering around in second line.
My ideal experience that I want is something like this -
Any ideas on how I can achieve this type of behavior? I have not written any code yet, because im not even sure how to go about doing it. Any help and pointers will greatly be appreciated. Hoping to get some answers from you all experts.
Edit 1: Adding screenshot based on Gavin's Flexbox suggestion
Sounds like an ideal case for FlexboxLayout. It acts like a LinearLayout but then wraps when it hits the end of a line.
I have a slight issue. I wanna do something like we have here where we put in format markers such as this and this but I want it to appear in the edit text but not remove the marks for it. At the moment I'm achieving this with a preview button which displays an AlertDialog to show the previewed text.
I'm not sure which code to show as I have no idea how to do this at all. I also have no idea where to start on something like this. I've tried doing tons of research and it formats one word and then completely removes the markup/down for it.
Any help will be appreciated and I'm happy to supply any code whatsoever :)
I achieved this using a third-party library RichEditor and took the ones that I needed. It works really well for what I needed so I would recommend it for people to use.
It uses a webview for the EditText and then converts the text into a WYSIWYG formatting.
I have a following issue with laying out text on Android. I'm basically trying to have two lines of text with minimal spacing and each should be styled differently. I've had quite good working solution with two singlelined TextViews one placed below the other, but I've been still getting a little bit cropped text on certain devices..
So I decided to switch to just one TextView an use Spannables instead which should be generally a better solution in all circumstances.
That means I needed to remove the single line property from my TextView -> in order to be able to wrap the line before starting the second Spannable..But there is an issue when is the text displayed at the first line actually longer than it..TextView wraps Automaticaly which is an unwanted behavior. Below you can see several screenshots, which should you better tell what I'm trying to achieve and where I'm now.
The first image shows new layout with spannables and you can see there the wrapped line as well.
The second image is the initial version of the layout woth two textviews layed out verically in a LinearLayout.
There is also a problem it's actually an appwidget, that means I do not have an access to that textview instance directly. I have been thinking about ditching textviews at all and instead use just ImageView and render all manually on canvas..That seems like an overkill to me, so I'm looking for a better solution. Unfortunately I'm kind of out of ideas and knowledge:)
Thank you
If you want to prevent a multi-word string from wrapping, you can replace the spaces with non-breaking spaces ('\u00A0'). TextView treats these as word characters, but renders them as spaces.
I'm looking for a way to have a grayed out text as prefix in an EditText. This text should be not selectable.
It's a bit like the To field when you're composing a message with Gmail. The only (visual) difference is that this text disappears when you start typing.
Is there any trick to achieve this in Android?
Thanks!
You can use an image of the part "EUR 2500". this you can display in your editbox without affecting the rest of the part. Follow the code:
Drawable editTextDrawable = context.getResources().getDrawable(imageId);
editTextDrawable.setBounds(0, 0, editTextDrawable.getIntrinsicWidth(),
editTextDrawable.getIntrinsicHeight());
The drawable can be used inside the edittext as follows:
editTxtItemName.setCompoundDrawables(,
ListViewConstants.editTextDrawable, null, null, null);
As an ultimate solution, you can rewrite the full EditText class by extending it and modifying it in a way that it has a custom Background set by you, and a predefined padding set by you.
Put the EUR as the background, positioning it in the left side, and then give the starting padding of the EditText in such a way that the text the user types, starts right after the EUR text.
This maybe regarded as an overkill or a poor-man's solution to this problem, but still its the ultimate option. Not the smartest one perhaps, and I also don't know if its gonna work for sure :P
All the best!
I have a textView which is configured as an EditText. But the problem is that the cursor doesn't appear when i'm pressing keys (text is written correctly).
Thanks
Well the first thing I'd try is setCursorVisible(true)
Also you say you have a TextView which is configured as an EditText. That's a bit confusing to me. Did you define it in your layout XML as <EditText> or create a new EditText object via new EditText(context)? Or did you define it as a <TextView> with android:editable="true"? Your wording sounds almost like you did the later, but I'm not sure that's going to work as well as the former.
For future reference, posting the code that's not working as part of your question really helps people pinpoint your problem and provide you the correct answer.