當前位置: 首頁>>代碼示例>>Java>>正文


Java AppBarLayout.setBackgroundColor方法代碼示例

本文整理匯總了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);
}
 
開發者ID:IdeaTrackerPlus,項目名稱:IdeaTrackerPlus,代碼行數:24,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:77,代碼來源:LineActivity.java


注:本文中的android.support.design.widget.AppBarLayout.setBackgroundColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。