If you use a Toolbar
, yes. she’s in the library appcompat-v7
and you must choose the Noactionbar theme for the app:
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>
Insert a Toolbar into your xml layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
app:titleTextColor="@android:color/white">
</LinearLayout>
Now in Activity identify the Toolbar:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Remembering that Activity should be the type AppCompatActivity
or ActionBarActivity
:
public class MeuActivity extends ActionBarActivity
Now your Toolbar is a View like any other. You can change the background color using:
int corVerde = Color.parseColor("#50a600");
toolbar.setBackgroundColor(corVerde);
It is possible yes, and there are several ways to do this. Cool would be to make a gridview with various colors. This way, as long as the user chooses a color, the theme changes accordingly.
– viana