Java how to set default color in android studio

Java how to set default color in android studio

To set the default color in Android Studio, you can use the colorPrimary attribute in the colors.xml file. This attribute specifies the default color to be used for the app bar and other UI elements.

To set the default color in colors.xml, add the following line:

r‮l:ot refe‬autturi.com
<color name="colorPrimary">#FF0000</color>

This will set the default color to red. You can use any color code you like.

You can also set the default color programmatically in your app's code. To do this, you can use the setColor() method of the ActionBar class.

For example:

import android.app.ActionBar;
import android.graphics.Color;

// ...

ActionBar actionBar = getActionBar();
actionBar.setColor(Color.RED);

This will set the default color of the action bar to red. You can use the setColor() method on any View object to set its background color.

Created Time:2017-11-03 23:27:12  Author:lautturi