Can we change the colour of title in an Android application.
I want to change the colour of label which has contents Abc Supply Company.
This label is in Manifest file. Can we change the colour for this label.
Looking forward to your reply.
thanks.
I think you want to change color of Application Label that comes in every screen.If i am right then there is no solution
In this case you have use theme for activity in android manifest file like this to remove that label
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
Then design you own custom Label in Layout and then you can do whatever you want to do.
Hope this help you :)
Solution for this is known as Custom Title bar in Android, check this article: http://coderzheaven.com/2011/06/custom-title-bar-in-android/
Of course you can do.
You need to get reference of your
Textview yourTextView = ( TextView ) findViewById( R.id.YOUR_TEXT_VIEW );
and then call the function setTextColor( YOUR COLOR );
Related
I have some intent with set of TextViews and a Button. If user clicks the button and there is some error I want to change look of one TextView. E.g. change the border to red and make font bold. I wrote a style for it but I have not found method setStyle on the TextView. After some self study I realized that Android does not support setting the style programmatically. There are some workarounds, when you create the intent source. But my intent already exists, it seems odd to recreate it.
Could you tell me the proper way?
use the workaround and create the TextView again
forget the styles and use java methods to decorate existing TextView
something else
Changing the style of the textview directly does not work as you know. But you can create a second textview with other styles in your layout, which you can show up if needed.
Just add this xml attribute android:visibility="gone" to the second textview, so this second textview is not displayed at first, but available.
When you now want to change the style of your textview, you simple need to swap the two textviews by hidding the first one and showing the second one
textView1.setVisibility(View.GONE);
textView2.setVisibility(View.VISIBLE);
I used these two answers to make it work:
https://stackoverflow.com/a/5488652/1639556
https://stackoverflow.com/a/14195090/1639556
and the code is:
ViewManager parent = (ViewManager) unknown.getParent();
parent.removeView(unknown);
TextView newUnknown = (TextView)getLayoutInflater().inflate(R.layout.tvtemplate, null);
newUnknown.setId(unknown.getId());
parent.addView(newUnknown, unknown.getLayoutParams());
unknown = newUnknown;
You can try using setTextAppearance() on the textview. The link is: setTextAppearance
Your style will need TextAppearance.SomeThing.SomeOtherThing as the parent.
Use R.style.YourStyleName as the integer argument.
I'm using action bar with custom view for title to be able to add Title and Subtitle
I need to set Title Style to Bold, When I make it in the XML layout it works fine, but I need to set it from code using
textView.setTypeface(null, Typeface.BOLD);
but it does not work, can anyone please help
Ideally it should work. This may sound mundane but can you check if it gets reset somewhere after you set it to bold the first time in your Java file.
You can use this code to display HTML codes in textviews
textView.setText(Html.fromHtml("<b>BOLD WORDS HERE</b>"));
I am trying to add a custom style to an Android NumberPicker. What I am trying to do is have the text displayed by the picker as white since by default (or according to the default theme on the device) I have it in black. The problem is that my app background is a dark color so I want the text to be white or something clear.
so I have something like this in my style.xml file :
<style name="myPicker">
<item name="android:textColor">#FFFFFF</item>
</style>
the textcolor attribute doesn't even exist on the NumberPicker widget but I just tried to add it so that my text color changes. It does not work of course. The only thing that can be customized on this widget seems to be the background
Now the question : how can we change the text color of the picker ?
if somebody has the same issue or has solved it then please let us know.
I have found an "ugly" way to do it. Just get a reference to the child views of the number picker widget. There are three (3) child views : the upper arrow, the textview (containing the text or value to be displayed) and the lower arrow.
Let's say we have a Number picker called np
np.setValue(10);
np.setMinValue(5);
np.setMaxValue(50);
// retrieve the textview reference
TextView npTextView = (TextView) np.giftAmount.getChildAt(1); // since indexing begins at 0
npTextView.setTextColor(getResources().getColor(
R.color.my_custom_color)
I know that's bad but it works ...
I want to know whether there is a way to change the alignment of activiy label, like other views can be aligned by android:gravity attribute..
NOTE: Except android:label=" Header "
Thanks in advance..
You have to customize Title Bar for that.
See the Examples Here :
http://www.londatiga.net/it/how-to-create-custom-window-title-in-android/
http://coderzheaven.com/2011/06/16/custom-title-bar-in-android/
You can customize according to your need.
Hallo everybody,
I'd like to use black color as default text color only in one activity.
I guess, I should use Theme and Styles, but I didn't find any good information relating to my question or to only one activity.
Is it possible to change default text color only for one activity?
If yes, could you give me an example please, how to do this?
Mur
You can add the android:theme tag to just an activity:
<activity
android:name=".SomeActivity"
android:theme="#style/Theme.ForSomeActivity"
/>