当前位置: 首页>>代码示例>>Java>>正文


Java CollapsingToolbarLayout.setStatusBarScrimColor方法代码示例

本文整理汇总了Java中android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrimColor方法的典型用法代码示例。如果您正苦于以下问题:Java CollapsingToolbarLayout.setStatusBarScrimColor方法的具体用法?Java CollapsingToolbarLayout.setStatusBarScrimColor怎么用?Java CollapsingToolbarLayout.setStatusBarScrimColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.CollapsingToolbarLayout的用法示例。


在下文中一共展示了CollapsingToolbarLayout.setStatusBarScrimColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ImageAnimator

import android.support.design.widget.CollapsingToolbarLayout; //导入方法依赖的package包/类
ImageAnimator(CollapsingToolbarLayout collapsingToolbar, ImageView targetImage, ImageView outgoingImage) {
    this.collapsingToolbar = collapsingToolbar;
    mTargetImage = targetImage;
    mOutgoingImage = outgoingImage;
    BindingUtils.loadImg(mTargetImage, mImages[0]);
    Resources mResources = App.getAppContext().getResources();
    int[] mColorDay = mResources.getIntArray(R.array.day_color_tab);
    int[] mColorNight = mResources.getIntArray(R.array.night_color_tab);
    mColors = SpUtil.isNight() ? mColorNight : mColorDay;
    collapsingToolbar.setContentScrimColor(mColors[0]);
    collapsingToolbar.setStatusBarScrimColor(mColors[0]);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ImageAnimator.java

示例2: setStatusBarColorForCollapsingToolbar

import android.support.design.widget.CollapsingToolbarLayout; //导入方法依赖的package包/类
/**
 * compat for CollapsingToolbarLayout
 */
public static void setStatusBarColorForCollapsingToolbar(Activity activity, final AppBarLayout appBarLayout, CollapsingToolbarLayout collapsingToolbarLayout,
                                                         Toolbar toolbar, int statusColor) {
    Window window = activity.getWindow();

    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(Color.TRANSPARENT);
    window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);

    ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
    View mChildView = mContentView.getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() {
            @Override
            public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                return insets;
            }
        });
        ViewCompat.setFitsSystemWindows(mChildView, true);
        ViewCompat.requestApplyInsets(mChildView);
    }

    ((View) appBarLayout.getParent()).setFitsSystemWindows(true);
    appBarLayout.setFitsSystemWindows(true);
    collapsingToolbarLayout.setFitsSystemWindows(true);
    collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(true);
    toolbar.setFitsSystemWindows(false);

    collapsingToolbarLayout.setStatusBarScrimColor(statusColor);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:StatusBarCompatLollipop.java

示例3: updateToolbarColors

import android.support.design.widget.CollapsingToolbarLayout; //导入方法依赖的package包/类
private void updateToolbarColors() {
        if (toolbar == null || toggle == null) {
            return;
        }

        int[] colors = ColorUtils.get2ToolbarTextColors(this);

        int mainTC = colors[0];
        toolbar.setTitleTextColor(mainTC);
        toggle.getDrawerArrowDrawable().setColor(mainTC);

        if (menu != null) {
            MenuItem search = menu.findItem(R.id.action_main_search);
            if (search != null) {
                Drawable icon = search.getIcon();
                if (icon != null) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        icon.setTint(mainTC);
                    }
                }
            }
        }

        CollapsingToolbarLayout coll = (CollapsingToolbarLayout) findViewById(R.id.activity_main_coll_tool_bar);
        int[] cs = ColorUtils.get2ActionStatusBarColors(this);
        coll.setStatusBarScrimColor(cs[0]);
        coll.setContentScrimColor(cs[1]);

        toolbar.setBackgroundColor(cs[1]);

        // 为了使状态栏透明,不要设置颜色
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            getWindow().setStatusBarColor(cs[0]);
        }
    }
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:36,代码来源:MainActivity.java

示例4: themeChange

import android.support.design.widget.CollapsingToolbarLayout; //导入方法依赖的package包/类
@Override
public void themeChange(ThemeEnum themeEnum, int[] colors) {

    ThemeEnum th = appPreference.getTheme();
    int[] cs = ColorUtils.get10ThemeColors(this, th);

    int statusC = cs[0];
    int toolbarC = cs[1];
    int accentC = cs[2];
    int mainBC = cs[3];
    int vicBC = cs[4];
    int mainTC = cs[5];
    int vicTC = cs[6];
    int navC = cs[7];
    int toolbarMainTC = cs[8];
    int toolbarVicTC = cs[9];

    adapter.themeChange(th, cs);

    optionsDialog.setTitleBarBgColor(vicBC);
    optionsDialog.setContentBgColor(mainBC);
    optionsDialog.setDivideColor(vicTC);
    optionsDialog.setTitleTextColor(mainTC);

    optionsAdapter.setTitleColor(mainTC);
    optionsAdapter.setIconColor(accentC);

    FirstThreeViewHolder[] holders = {first, second, third};
    for (FirstThreeViewHolder holder : holders) {
        holder.number.setTextColor(mainBC);
        holder.name.setTextColor(mainTC);
        holder.arts.setTextColor(vicTC);

        holder.time.setTextColor(toolbarMainTC);
        holder.time.setBackgroundColor(accentC);
    }

    line.setBackgroundColor(accentC);
    title.setTextColor(mainTC);

    CollapsingToolbarLayout coll = (CollapsingToolbarLayout) findViewById(R.id.rmp_a_coll_toolbar);
    int[] ta = ColorUtils.get2ActionStatusBarColors(this);
    coll.setStatusBarScrimColor(ta[0]);
    coll.setContentScrimColor(ta[1]);

    toolbar.setBackgroundColor(ta[1]);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(ta[0]);
    }

}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:52,代码来源:RecentMostPlayActivity.java

示例5: onServiceConnected

import android.support.design.widget.CollapsingToolbarLayout; //导入方法依赖的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.CollapsingToolbarLayout.setStatusBarScrimColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。