This is the code of a compound view I wrote. It uses android.support.v7.widget.CardView as parent class:
public class ItemListItem extends CardView {
TextView tvName;
ImageView ivIcon;
public ItemListItem(Context context) {
super(context, null, R.style.GreenCardView);
LayoutInflater.from(context).inflate(R.layout.item_list_item, this, true);
tvName = (TextView) findViewById(R.id.tvName);
ivIcon = (ImageView) findViewById(R.id.ivIcon);
}
public void setItem(Item item)
{
tvName.setText(item.getName());
}
}
Although I'm adding a custom style (R.style.GreenCardView) to the super constructor call at line 7, it initializes every instance of this class with the default white style. Why is this the case?
edit:
style
<style name="GreenCardView" parent="CardView.Dark">
<item name="contentPadding">#dimen/default_margin</item>
<item name="cardBackgroundColor">#color/guiColor</item>
<item name="cardElevation">#dimen/cardElevation</item>
<item name="cardCornerRadius">#dimen/cardCornerRadius</item>
<item name="android:foreground">?android:attr/selectableItemBackground</item>
</style>
The third argument to the View constructor needs to be a theme attribute, e.g. R.attr.myCardViewStyle. You will need to specify the value of the attribute in your app theme and define the attribute in attrs.xml.
res/values/attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<attr name="myCardViewStyle" format="reference" />
</resources>
res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<style name="AppTheme" parent="...">
...
<item name="myCardViewStyle">#style/GreenCardView</item>
</style>
</resources>
Related
I have a custom attribute say like this :
<attr name="colorPrimarySdk" format="color"/>
<attr name="colorSecondarySdk" format="color"/>
<attr name="colorAccentSdk" format="color"/>
And I am using them in my styles like this:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">?colorPrimarySdk</item>
<item name="colorPrimaryDark">?colorSecondarySdk</item>
<item name="colorAccent">?colorAccentSdk</item>
</style>
Now what I want is to set the value of my attributes dynamically from the code like, say :
colorPrimarySdk.value = myCustomColor
I have already tried using TypedValue and accessing the attribute itself.
If anyone can help changing the value for my custom attribute, that would be a great help. Thanks in advance.
it's hard :)
colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="your_special_color">#FF0099CC</color>
</resources>
Res.java:
public class Res extends Resources {
public Res(Resources original) {
super(original.getAssets(), original.getDisplayMetrics(), original.getConfiguration());
}
#Override public int getColor(int id) throws NotFoundException {
return getColor(id, null);
}
#Override public int getColor(int id, Theme theme) throws NotFoundException {
switch (getResourceEntryName(id)) {
case "your_special_color":
// You can change the return value to an instance field that loads from SharedPreferences.
return Color.RED; // used as an example. Change as needed.
default:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return super.getColor(id, theme);
}
return super.getColor(id);
}
}
}
BaseActivity.java
public class BaseActivity extends AppCompatActivity {
...
private Res res;
#Override public Resources getResources() {
if (res == null) {
res = new Res(super.getResources());
}
return res;
}
...
}
Define the colors for the specific theme in your colors file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="my_link_color1">#0077CC</color>
<color name="my_link_color2">#626262</color>
</resources>
Create file res/values/attrs.xml with contents:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="myLinkColor" format="reference" />
</resources>
Suppose we have 2 themes in our styles.xml (Theme1 and Theme2) define:
<style name="Theme1" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="myLinkColor">#color/my_link_color1</item>
</style>
<style name="Theme2" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="myLinkColor">#color/my_link_color2</item>
</style>
Use the color in the XML:
android:textColor="?attr/myLinkColor"
I try to create set of TextView programmatically but a want to customize each TextView by xml style. I create TextView instances and place it into LinearLayout.
In my style.xml script I add custom values for text size and color, and all work fine.
But I cant't set text alignment to center by my styles.xml file.
It's my java code snippet:
import android.view.View;
public class GramophoneForm extends AppCompatActivity
{
private LinearLayout m_button_container = null;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
....
....
m_button_container = this.findViewById(R.id.gr_view_container);
List<? extends Object> ct_list = getClassificationTypes();
setObjectsList(ct_list);
}
public void setObjectsList(List<? extends Object> objects)
{
m_button_container.removeAllViews();
for(Object o : objects)
{
TextView item = new TextView(this);
item.setTextAppearance(this, R.style.selectionTextStyle);
////////////////////Is't works fine, but I want set up text alignment by xml style
item.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
////////////////////
item.setText(o.toString());
item.setTag(o);
m_button_container.addView(item);
}
}
}
My styles.xml code snippet:
<style name="selectionTextStyle" parent="#android:style/Widget.TextView">
<item name="android:layout_width">match_parent</item>
<item name="android:textSize">25dp</item>
<item name="android:textColor">#FFFF00FF</item>
<item name="android:textStyle">bold</item>
<!-- don't work -->
<item name="android:layout_centerInParent">true</item>
<!-- don't work
<item name="android:textAlignment">4</item>
-->
<!--don't work
<item name="android:textAlignment">center</item>
-->
</style>
A possible solution for your problem is to create a XML layout with a TextView with the style applied to it, and instead of creating an instance of TextView every time, inflate the layout.
XML example, lets say its named myTextViewLayout:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/selectionTextStyle" />
And in your for loop inflate it and add it to the container:
for(Object o : objects){
TextView item = (TextView)getLayoutInflater().inflate(R.layout.myTextViewLayout, null);
item.setText(o.toString());
item.setTag(o);
m_button_container.addView(item);
}
You should insert a dimension value within the style xml:
<dimen name="buttonHeight">40px</dimen>
Then you simply should reference the dimension value. So in your layout file you'll write:
android:layout_height="#dimen/buttonHeight"
change your parent attribute from this parent="#android:style/Widget.TextView" to this android:Widget.Material.Light.TextView hope it will work!
If the android:tint attribute is set for a ViewGroup, should it apply to all descendant View's, or does it need to be applied to each individually?
The LinearLayout below (ButtonBar$LabeledButton) contains an ImageView and TextView that each specify their own color state list (CSL).
I'd like to set android:tint once in the ViewGroup so when it is disabled, all its members become disabled and change their tint accordingly (and also without having to override the setEnabled).
resources/layout/buttonbar_labeledbutton_addnew.axml
<?xml version="1.0" encoding="utf-8"?>
<!--LinearLayout-->
<view class="ButtonBar$LabeledButton"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ButtonBar_LabeledButton_AddNew"
style="#style/ButtonBar_LabeledButton">
<ImageView
android:id="#+id/ButtonBar_LabeledButton_Image"
style="#style/ButtonBar_LabeledButton_Image"
android:src="#drawable/v__ic_add_circle_outline_black_24dp"/>
<TextView
android:id="#+id/ButtonBar_LabeledButton_Label"
style="#style/ButtonBar_LabeledButton_Label"
android:text="Add New"/>
</view>
<!--/LinearLayout-->
resources/values/styles.xml
<!--LinearLayout-->
<style name="ButtonBar_LabeledButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">horizontal</item>
<??-item name="android:tint">#color/buttonbar_csl</item-??>
</style>
<!--ImageView-->
<style name="ButtonBar_LabeledButton_Image">
<item name="android:layout_width">40dp</item>
<item name="android:layout_height">40dp</item>
<item name="android:tint">#color/buttonbar_csl</item>
</style>
<!--TextView-->
<style name="ButtonBar_LabeledButton_Label">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">#color/buttonbar_csl</item>
<!--item name="android:tint">#color/buttonbar_csl</item-->
</style>
ButtonBar.LabeledButton
[Register("ButtonBar$LabeledButton")]
public class LabeledButton : LinearLayout
{
public LabeledButton(Context context, IAttributeSet attributes) : base(context, attributes) { }
public override bool Enabled
{
set
{
var image = FindViewById<ImageView>(Resource.Id.ButtonBar_LabeledButton_Image);
if( image != null )
image.Enabled = value;
var label = FindViewById<TextView>(Resource.Id.ButtonBar_LabeledButton_Label);
if( label != null )
label.Enabled = value;
base.Enabled = value;
}
}
}
Update
Attributes
Every View and ViewGroup object supports their own variety of XML
attributes. Some attributes are specific to a View object (for
example, TextView supports the textSize attribute), but these
attributes are also inherited by any View objects that may extend this
class. Some are common to all View objects, because they are inherited
from the root View class (like the id attribute). And, other
attributes are considered "layout parameters," which are attributes
that describe certain layout orientations of the View object, as
defined by that object's parent ViewGroup object.
android:tint is specific to ImageView, and is ignored. I didn't inspect the attribute set in ButtonBar$LabeledButton's inflation constructor to see if it is at lest present to work with. Declaring a custom attribute would solve this, but then it's assignment to the ImageView and TextView in their now required custom classes' inflation constructors would be obscured (I prefer to leverage the framework as much as possible to minimize any extra, one-off code b/c of the maintenance and potential point-of-failure it introduces).
ButtonBar
public class ButtonBar : LinearLayout
{
public ButtonBar(Context context, IAttributeSet attributes) : base(context, attributes) { }
public override bool Enabled
{
set
{
SetChilderenEnabled(value);
base.Enabled = value;
}
}
private void SetChilderenEnabled(bool value)
{
for (int i = 0; i < ChildCount; i++)
{
GetChildAt(i).Enabled = value;
}
}
[Register("us.sam.views.ButtonBar$LabeledButton")]
public class LabeledButton : LinearLayout
{
private ImageView _buttonIV;
private TextView _labelTV;
private int _buttonIV_src;
private string _labelTV_text;
public override bool Enabled
{
set
{
if (_buttonIV != null)
_buttonIV.Enabled = value;
if (_labelTV != null)
_labelTV.Enabled = value;
base.Enabled = value;
}
}
public LabeledButton(Context context, IAttributeSet attributes) : base(context, attributes)
{
ReadAttributes(context, attributes);
LayoutInflater inflater = LayoutInflater.From(context);
_labelTV = (TextView)inflater.Inflate(Resource.Layout.ButtonBar_LabeledButton_LabelTextView, this, false);
_buttonIV = (ImageView)inflater.Inflate(Resource.Layout.ButtonBar_LabeledButton_ButtonImageView, this, false);
_labelTV.Text = _labelTV_text;
_buttonIV.SetImageResource(_buttonIV_src);
AddViewInLayout(_buttonIV, ChildCount, _buttonIV.LayoutParameters);
AddViewInLayout(_labelTV, ChildCount, _labelTV.LayoutParameters);
}
private void ReadAttributes(Context context, IAttributeSet attributes)
{
Android.Content.Res.TypedArray typedArray = context.ObtainStyledAttributes(attributes, Resource.Styleable.LabeledButton);
_buttonIV_src = typedArray.GetResourceId(Resource.Styleable.LabeledButton_button_imageview_src, 0);
_labelTV_text = typedArray.GetString(Resource.Styleable.LabeledButton_label_textview_text);
typedArray.Recycle();
}
}
}
recordexpandablelistview_groupbuttonbar_trecords.axml
<?xml version="1.0" encoding="utf-8"?>
<!--LinearLayout-->
<view class="us.sam.RecordsView$RecordExpandableListView$GroupButtonBar"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RecordExpandableListView_GroupButtonBar_TRecords"
style="#style/RecordExpandableListView_GroupButtonBar">
<!--LinearLayout-->
<us.sam.Views.ButtonBar
android:id="#+id/ButtonBar"
style="#style/ButtonBar">
<include layout="#layout/ButtonBar_LabeledButton_AddNew"/>
</us.sam.Views.ButtonBar>
<ImageView style="#style/ListItem_Divider_Horizontal"/>
</view>
ButtonBar_LabeledButton_AddNew.axml
<?xml version="1.0" encoding="utf-8"?>
<!--LinearLayout-->
<view class="us.sam.views.ButtonBar$LabeledButton"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ButtonBar_LabeledButton_AddNew"
style="#style/ButtonBar_LabeledButton"
button_imageview_src="#drawable/v__ic_add_circle_outline_black_24dp"
label_textview_text="#string/ButtonBar_LabeledButton_LabelTextView_Text_AddNew">
</view>
ButtonBar_LabeledButton_ButtonImageView.axml
<?xml version="1.0" encoding="utf-8"?>
<!--<view class="us.sam.views.ButtonBar$LabeledButton$Button"-->
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ButtonBar_LabeledButton_ButtonImageView"
style="#style/ButtonBar_LabeledButton_ButtonImageView"/>
<!--android:src="#drawable/v__ic_add_circle_outline_black_24dp"-->
ButtonBar_LabeledButton_LabelTextView.axml
<?xml version="1.0" encoding="utf-8"?>
<!--view class="us.sam.views.ButtonBar$LabeledButton$Label"-->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ButtonBar_LabeledButton_LabelTextView"
style="#style/ButtonBar_LabeledButton_LabelTextView"/>
<!--android:text="Add New"-->
styles.xml
<!--LinearLayout-->
<style name="RecordExpandableListView_GroupButtonBar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:orientation">vertical</item>
<!--use isChildSelectable() override in BaseExpandableListAdapter instead-->
<!--item name="android:clickable">true</item-->
</style>
<!--LinearLayout-->
<style name="ButtonBar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">horizontal</item>
</style>
<!--LinearLayout-->
<style name="ButtonBar_LabeledButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:orientation">horizontal</item>
</style>
<!--ImageView-->
<style name="ButtonBar_LabeledButton_ButtonImageView">
<item name="android:layout_width">40dp</item>
<item name="android:layout_height">40dp</item>
<item name="android:tint">#color/button_bar_csl</item>
</style>
<!--TextView-->
<style name="ButtonBar_LabeledButton_LabelTextView">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">#color/button_bar_csl</item>
</style>
<style name="ListItem_Divider_Horizontal">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1px</item>
<item name="android:background">#android:color/black</item>
</style>
I used app compat theme style .
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:itemTextAppearance">#style/myCustomMenuTextApearance</item>
<item name="android:listPopupWindowStyle">#style/PopupMenuStyle</item>
</style>
<style name="PopupMenuStyle" parent="Widget.AppCompat.ListPopupWindow">
<item name="android:divider">#drawable/devider</item>
<item name="android:dividerHeight">2dp</item>
</style>
<style name="PopupMenu" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#color/search_panel_color</item>
<item name="android:textColor">#color/activity_button_text_color</item>
<item name="android:shadowColor">#color/activity_theam_color</item>
</style>
<style name="myCustomMenuTextApearance" parent="#android:style/TextAppearance.Widget.TextView.PopupMenu">
<item name="android:textColor">#color/activity_theam_color</item>
</style>
I want to add a divider in my menu item.
I've tried so many things, but the divider is not applying...
Is there any way to show the divider?
I also have the same problem. The solution is like this:
<style name="PopupMenuListView" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:divider">#000000</item>
<item name="android:dividerHeight">1dp</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:dropDownListViewStyle">#style/PopupMenuListView</item>
</style>
You can also refer to the following link:
How to add dividers between specific menu items?
I have one solution.you can design popup as per your choice by programming.use below code to display popup menu.
private ListPopupWindow listPopupWindow;
listPopupWindow = new ListPopupWindow(getApplicationContext());
listPopupWindow.setWidth(400);
listPopupWindow.setDropDownGravity(Gravity.CENTER);
listPopupWindow.setAdapter(new listpopupadapter(a, type));
listPopupWindow.setAnchorView(v);
listPopupWindow.show();
Here listpopupadapter is class to design your list as it below.
public class listpopupadapter extends BaseAdapter {
ArrayList<String> a;
String type;
public listpopupadapter(ArrayList<String> a, String type) {
this.a = a;
this.type = type;
}
#Override
public int getCount() {
return a.size();
}
#Override
public Object getItem(int position) {
return getItem(position);
}
#Override
public long getItemId(int position) {
return position;
}
#SuppressLint("ViewHolder")
#Override
public View getView(final int position, View convertView,
ViewGroup parent) {
// TODO Auto-generated method stub
View root = LayoutInflater.from(parent.getContext()).inflate(
R.layout.raw_filter, null);
}
}
From your theme style, I guessed you used Toolbar. Is your menu popup is showed from Toolbar? If so, you can customize as the following step.
Define the theme
<style name="AppToolbarPopupTheme" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="android:dropDownListViewStyle">#style/AppDropDownListViewStyle</item>
</style>
<style name="AppDropDownListViewStyle" parent="Widget.AppCompat.ListView.DropDown">
<item name="android:divider">#drawable/line_divider</item>
<item name="android:dividerHeight">1dp</item>
</style>
Then apply the theme to Toolbar
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:popupTheme="#style/AppToolbarPopupTheme">
</android.support.v7.widget.Toolbar>
if you haven't found the answer to this question then this is how it worked for me using the style:
<style name="PopupMenu">
<item name="android:itemBackground">#color/background_medium_gray</item>
<item name="android:background">#android:color/transparent</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:colorBackground">#color/BackgroundGray</item>
<item name="android:dividerHeight">1dp</item>
</style>
Context context = new ContextThemeWrapper(getActivity(), R.style.PopupMenu);
final PopupMenu popupMenu = new PopupMenu(context, view);
final MenuInflater menuInflater = popupMenu.getMenuInflater();
I suggest you add dummy groups,try this way
<group>
<!--add it like as a separator-->
<item
android:title=""
android:showAsAction="always"
android:enabled="false" />
</group>
Using a Material theme removes dividers.May be this is the simple solution to this problem.
You can try this or any holo theme (i.e #android:style/Widget.ListPopupWindow) to get divider effect in popup
<!-- Change Overflow Menu ListView Divider Property -->
<style name="PopupMenuListView" parent="android:Widget.ListPopupWindow">
<item name="android:divider">#FF0000</item>
<item name="android:dividerHeight">2dp</item>
</style>
I've made a driver app that needed a popup the ride was coming, at that time I used this one. So please try this one. Maybe it will help.
<activity
android:name="driver_activity_name
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
I want to be able to change the background color of my app so that whenever i want to change the color during runtime, i can just press a button in the app to change the background color. After the changing the color i want that it should stay there whenever i open the app again. Also i would like to know how to change the color of other activities while I am in another activity.
Thanks in advance.
my colors.xml:
<resources>
<color name="original">#25383C</color>
<color name="grey">#484849</color>
<color name="red">#881A27</color>
<color name="orange">#ffa500</color>
<color name="yellow">#CDE707</color>
<color name="green">#00ff00</color>
<color name="aqua">#00FFCC</color>
<color name="marine">#0C0C84</color>
<color name="purple">#630A86</color>
<color name="silver">#c0c0c0</color>
styles.xml(it has themes):
<resources>
<style name="original">
<item name="android:background">#25383C</item>
</style>
<style name="grey">
<item name="android:background">#484849</item>
</style>
<style name="red">
<item name="android:background">#881A27</item>
</style>
<style name="orange">
<item name="android:background">#ffa500</item>
</style>
<style name="yellow">
<item name="android:background">#CDE707</item>
</style>
<style name="green">
<item name="android:background">#00ff00</item>
</style>
<style name="aqua">
<item name="android:background">#00FFCC</item>
</style>
<style name="marine">
<item name="android:background">#0C0C84</item>
</style>
<style name="purple">
<item name="android:background">#630A86</item>
</style>
<style name="silver">
<item name="android:background">#c0c0c0</item>
</style>
You can use Android Shared Preferences to remember the selected background color for the app.So every time you open the app you can check the value of the shared preference and apply the color accordingly.
Use a common base activity class that all the other activities will derive and in the "OnCreate" and "OnResume" methods write the code to read shared preference value and apply back ground color.This way when you open any activity selected background color will be applied.
Try below code, it is tested and working.
BaseActivity Class
public class BaseActivity extends ActionBarActivity {
private static final String PREFS_NAME="color_settings";
SharedPreferences prefsReader = null;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
prefsReader=getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
}
#Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
setBackgroundColor();
}
protected void setBackgroundColor()
{
int background_resource_id= prefsReader.getInt("background_resource_id",0);
View bgView= findViewById(R.id.main_container);
bgView.setBackgroundColor(getResources().getColor(background_resource_id));
}
protected void setCurrentBackgroundColor(int colorResourceId)
{
SharedPreferences.Editor editor=getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit();
editor.putInt("background_resource_id", colorResourceId);
editor.commit();
}
}
Activity Class
public class MainActivity extends BaseActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//save the color resource value in shared pref
setCurrentBackgroundColor(R.color.red);
setContentView(R.layout.activity_main);
}
}
Colors.xml color list
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="blue" type="color">#FF33B5E5</item>
<item name="purple" type="color">#FFAA66CC</item>
<item name="green" type="color">#FF99CC00</item>
<item name="orange" type="color">#FFFFBB33</item>
<item name="red" type="color">#FFFF4444</item>
<item name="darkblue" type="color">#FF0099CC</item>
<item name="darkpurple" type="color">#FF9933CC</item>
<item name="darkgreen" type="color">#FF669900</item>
<item name="darkorange" type="color">#FFFF8800</item>
<item name="darkred" type="color">#FFCC0000</item>
</resources>
For doing such thing you can maintain a database to store the values for the different colors.
Now, Whenever you press the button after choosing the particular color for your application you just have to update the color value in your database.
In onCreate() method of your MainActivity(Launcher Activity), You just have to retrieve the color value from the field of database and can set it in your application.