本文整理汇总了Java中android.support.design.widget.AppBarLayout.setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java AppBarLayout.setBackgroundColor方法的具体用法?Java AppBarLayout.setBackgroundColor怎么用?Java AppBarLayout.setBackgroundColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.AppBarLayout
的用法示例。
在下文中一共展示了AppBarLayout.setBackgroundColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changePrimaryColor
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
private void changePrimaryColor() {
//disable search mode for tabLayout
disableSearchMode();
AppBarLayout appbar = (AppBarLayout) findViewById(R.id.appbar);
mToolbar.setBackgroundColor(mPrimaryColor);
tabLayout.setBackgroundColor(mPrimaryColor);
appbar.setBackgroundColor(mPrimaryColor);
if (Build.VERSION.SDK_INT >= 21) {
getWindow().setStatusBarColor(darken(mPrimaryColor));
}
if (rightDrawer != null) {
mColorItem1.withIconColor(mPrimaryColor);
rightDrawer.updateItem(mColorItem1);
}
RecyclerOnClickListener.setPrimaryColor(mPrimaryColor);
}
示例2: onServiceConnected
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onServiceConnected(ComponentName className,
IBinder service) {
// We've bound to LocalService, cast the IBinder and get LocalService instance
binder = (MainService.LocalBinder) service;
mainService = binder.getService();
locBound = true;
Network net = mainService.getNetwork(networkId);
Line line = net.getLine(lineId);
String title = String.format(getString(R.string.act_line_title), line.getName());
setTitle(title);
getSupportActionBar().setTitle(title);
AppBarLayout abl = (AppBarLayout) findViewById(R.id.app_bar);
final CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
ctl.setTitle(title);
int color = line.getColor();
ctl.setContentScrimColor(color);
ctl.setStatusBarScrimColor(color);
abl.setBackgroundColor(color);
Drawable drawable = ContextCompat.getDrawable(LineActivity.this, Util.getDrawableResourceIdForLineId(line.getId()));
drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35, getResources().getDisplayMetrics());
FrameLayout iconFrame = new FrameLayout(LineActivity.this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(height, height);
int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
params.setMarginEnd(margin);
}
params.setMargins(0, 0, margin, 0);
iconFrame.setLayoutParams(params);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
iconFrame.setBackgroundDrawable(drawable);
} else {
iconFrame.setBackground(drawable);
}
lineIconsLayout.addView(iconFrame);
abl.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (ctl.getHeight() + verticalOffset < 2.5 * ViewCompat.getMinimumHeight(ctl)) {
lineIconsLayout.animate().alpha(0);
} else {
lineIconsLayout.animate().alpha(1);
}
}
});
Map<String, LineStatusCache.Status> statuses = mainService.getLineStatusCache().getLineStatus();
if (statuses.get(line.getId()) != null &&
statuses.get(line.getId()).down) {
disturbancesWarningLayout.setVisibility(View.VISIBLE);
} else {
disturbancesWarningLayout.setVisibility(View.GONE);
}
LinearLayout closedLayout = (LinearLayout) findViewById(R.id.closed_info_layout);
if (line.isExceptionallyClosed(new Date())) {
TextView closedView = (TextView) findViewById(R.id.closed_info_view);
Formatter f = new Formatter();
DateUtils.formatDateRange(LineActivity.this, f, line.getNextOpenTime(), line.getNextOpenTime(), DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
closedView.setText(String.format(getString(R.string.act_line_closed_schedule), f.toString()));
closedLayout.setVisibility(View.VISIBLE);
} else {
closedLayout.setVisibility(View.GONE);
}
populateLineView(LineActivity.this, getLayoutInflater(), net, line, lineLayout);
}