I want to put html codes on buttons as text in my android application and style them.
For ex: I want to create a help button and put "❔" as text to it.
Below is the code I have written in the activity.
Button btHelp=((Button) findViewById(R.id.btHelp));
btHelp.setText(Html.fromHtml("❔"));
But if I want to change the color of it. I tried by giving span and font in the above statement but it is not applying.
Can you please let me know how to give the colors for this. Also let me know if there is any better way to do so.
Thanks,
If you want to change text color, simply use:
btnHelp.setTextColor(Color.parseColor("#FF0000"));
or
btnHelp.setTextColor(Color.RED);
or
btnHelp.setTextColor(getResources().getColor(R.color.red));
But that won't work with emojis like your White Question Mark Ornament. If you want to change that question mark color, you will have to make a drawable file with button drawables (png) that have that question mark with the color you want. You can do that from photoshop or any other program.
Related
Anyone knows how to get the text of any component like textview, button, or edit text with it is current font style.
My issue is that I am getting a normal text with text view.getText() but I want to text with the custom font which I have applied with Typeface.
Thanks in advance
Share your code and what you have done until now in your thread, if you get error include it to your post. Here guide for asking in SO Guide Ask in SO
I have just a edittext on a card, created with relativelayout. When i double press on it, to mark it, the color of the two markes, right and left from the text a bit lower, have the same color as the card, because of that i want to change the color of the markers. The bar above the toolbar, and under the statusbar, is currently white, how u can see on the picture, that i want to change too, with animations and colors :D Maybe somebody can help me at my difficulties
Thanks in advance :)
It looks currently like this:
Try using android:textColorHighlight in your edit text
Just got the answer by myself :D I just pasted following line in my styles.xml
<item name="colorControlActivated">#607D8B</item>
I was surfing on the internet and by chance I got this image ..
http://blog.donnfelker.com/wp-content/uploads/2011/11/qonqr-example.png
So I tried to put a backgroung color to my activity but the problem is that the whole activity is being covered by that color .. what to do if i don't want the colors to be applied on the EditText fields ...?
And please also tell how to get this TextView style as in the image written "Create an account" ?
P.S. I am a newbie .
Try to split your activity into different layouts.and then apply background colors to those layouts.And for edittext you set its different background .
I have a text field, and on Android 2.2, when it is in focus or being used, it highlights it and puts an orange boarder around it.
The orange really doesn't look good with the other colors in my app, so I am wondering if there is any way to change that to a different color...
Thanks in advance.
You can write selectors for your textview using which you can change the appearance of your textview when it is selected.
You can refer to this:
http://developer.android.com/reference/android/content/res/ColorStateList.html
I want to change the style of a button in an android app. here is a picture that has both kinds of buttons, the one that I have now, and the one that I want to switch to:
the kinds of buttons that I am using now, look like any of the letters on that keyboard. the ones that I want to use like like the arrows. I would I go about changing this. I prefer to do it in xml but I can do it in java if that is the only way. Thanks
change the background of the Button to a png image with arrows!
in XML use android:background="#drawable/yourimage"
To get more sophisticated control check here,
Standard Android Button with a different color