is there an easy way to create a text view with an icon inside the text?
like in this number of rates example:
(** 3,45642)
(I have less then reputeshion 10 so I cant insert the image I wanted
** means an icon of a small man)
or is it part of RatingBar that i couldn't find?
I don't want to use android:drawableLeft="#drawable/my_icon"
as i feel like the parenthesis are critical.
Many thanks for any help!
Check out SpannableStringBuilder class.
Usage examples are posted here:
http://www.programcreek.com/java-api-examples/index.php?api=android.text.SpannableStringBuilder
Related
I have a text that is sometimes too high and at times one word.
How to put the text in this TextView so that the first two lines are located around the specified spacing?
Should this be done by 2 TextView?
If yes, how can I figure out how much text is placed on the top two lines?
You can use a Spannable to add customizations to a string inside a TextView.
The styling android blog has an excellent post about it: https://blog.stylingandroid.com/introduction-to-spans/
But looking to your print, it seems that the first row will always have a style and the rest another. With this, using two TextViews and customizing the view directly is a better option for code and performance.
Let I have some number n. It can be equal to any integer number ranged between 2 and 15,for example. And according to this number, I need to show n TextView's(orButtons). I need this concept for creating kind of 4 pic 1 word quiz game. As you know, in this game , if secret word is banana,then app create 6 places for each letter. And my question is what kind of concepts to use in order to solve this problem? My idea for solution was following: creating some view and add to this view a TextView n times. But I don't think that it is right way to do that. Can you tell me what I have to use in order to achieve my goal?
Loads of ways to achieve this:
You couid just create the placeholders you want in an XML Layout, I would of thought EditText with maxLength=1 and then use .setVisibility to show the ones you need depending on question;
You could use a loop to generate the number of elements you want. See
here for code example
Yesterday I asked a question about the TextView. I read and I see that it's very difficult to understand. So, I'm sorry.
Now I explain better my problem:
I try to personalize my TextView. I tried two different things:
I use photoshop, I made an image text and I use it as a drawable. The image re-sized isn't with right quality
I try to use the text of TextView, but I can't change the family of the text (the app crashed). Then I don't know how to set gradient as text color and border in the text.
What can I do?
Edit: yes! For the point 1 I use an ImageView inside of TextView. In point 2 I use TextView. I have problem in both situation!
I think to customize textview (any view) you have to implement your own custom view by creating your custom class.
Here is link for custom text view,i hope i will find it useful
http://www.jayway.com/2012/06/25/creating-custom-android-views-part-1-extending-standard-views-and-adding-new-xml-attributes/
Folks,
In my social networking application, single-line messages come from various users. As the message comes in, I need to display them in our UI as a single line that shows the time, the user, and the message line. All 3 fields need to be colored differently.
I tried to use TextView but am running into a problem. As I need various colors, I thought of using SpannableString but the problem is that TextView.Append does not support SpannableString as a parameter.
The other thought I had was to build html style text as each line comes in.
I am wondering if I am overlooking something. Perhaps there is a better user control or a better way to achieve my objective.
Thank you in advance for your help.
Regards,
Peter
Use Html and with help of <font color><font/> tag, you can set single text with different color#
String result="<font color=color_code>First Textview</font> <font color=color_code>Second Textview</font><font color=color_code>Third TextView</font>";
textview.setText(Html.fromHtml(result));
You should use three different text fields, nest them in a table layout using columns, or a relative layout. That way they will automatically resize no matter what length.
You can also use the android:weight tag to control how much room each one takes up.
The reason is that usually its 1 label per field in data structure. As per MVC software design pattern.
I'm looking forward to create an EditText with an Icon on the right that has some kind of functionality.
I've seen that the Google IO 2013 app has something like that on the search widget.
I want to know if its possible to do that with a simple EditText.
I've tried with a simple ImageView on the right of the EditText, but it looks really bad.
I would really appreciate if someone could point me in the right direction.
Thanks.
EDIT 1
This is an example of what I want. It looks really good. I have used the drawableRight and it doesn't look this good.
http://img836.imageshack.us/img836/1521/6faa.png
EDIT 2
I managed to build something that looks really similar to the SearchWidget with the voice recognition option.
I put two EditText next to each other (with a RelativeLayout), and set the margin left for the one on the right to -10dp. This way it looks like one EditText. I know this is not proper, but right now does what I want.
My problem now is the image, I'm using a 32x32 px image, because it fits fine, but it has really low quality, I'll look into that.
http://img560.imageshack.us/img560/9394/ilwp.png
You can definitely use a custom EditText with drawableRight as follows:
android:drawableRight="#drawable/your_drawable"
Refer
1.Custom EditText- 1
2.Custom EditText- 2