我正在尝试像 google play 商店一样设置操作栏颜色。
下面的代码尝试但得到完全像 play 商店。
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.testresult);
bar = getSupportActionBar();
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
@SuppressLint("NewApi")
@Override
public void onGenerated(Palette palette) {
Palette.Swatch vibrant = palette.getVibrantSwatch();
if (vibrant != null) {
// If we have a vibrant color
// update the title TextView
bar.setBackgroundDrawable(new ColorDrawable(vibrant
.getRgb()));
// titleView.setBackgroundColor(
// vibrant.getRgb());
// titleView.setTextColor(
// vibrant.getTitleTextColor());
}
}
});
}
操作栏透明背景。
滚动
请帮帮我...
最佳答案
可以通过调用操作栏上的 setDisplayHomeAsUpEnabled(true) 方法启用操作栏向上导航。通过调用此函数,将在操作栏上显示后退箭头。
//get action bar
ActionBar actionBar = getActionBar();
// Enabling Up / Back navigation
actionBar.setDisplayHomeAsUpEnabled(true);
要应用操作栏的背景颜色,请使用 setBackgroundDrawable() 方法并按如下方式传递 ColorDrawable 实例:
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FCFCFC")));
希望对你有帮助
关于android - 如何像 Google Play 商店一样更改操作栏颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27616506/