2016-08-15 43 views

回答

1

我想你的意思是AppBar的颜色。 您可以在色彩搭配

ActionBar bar = getActionBar(); 
bar.setBackgroundDrawable(new ColorDrawable(getRes‌​ources().getColor(R.c‌​olor.mycolor)); 

增加价值做到这一点:

<color name="mycolor">#FFFFFF</color> 

答案是从这里: Change action bar color in android

0

如果你想在XML做 试试这个tutorial from google

如果您想在代码中设置它:

public class MainActivity extends AppCompact { 

     @Override 
     protected void onCreate(final Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     ActionBar actionBar = getActionBar(); 
     actionBar.setBackgroundDrawable(new ColorDrawable(Color.BLUE)); // set your desired color 
     ... 
     } 
    ... 
    } 
+0

我将它放在代码中的位置? –

+0

在您的setContentView(您的xml)之后,在您的onCreate()方法中为此活动道歉。放置这个,迫使视图图纸生效。 – sumandas

+0

我不确定我是否正确设置了这个设置,我没有看到 –