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


Java Toolbar.getNavigationIcon方法代码示例

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


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

示例1: initPrevState

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private ToolbarState initPrevState(Toolbar toolbar) {
    ToolbarState prevState = new ToolbarState();
    if (toolbar.getBackground() != null) {
        prevState.toolbarColor = ((ColorDrawable) (toolbar.getBackground())).getColor();
    }
    Context context = toolbar.getContext();
    TypedValue typedValue = new TypedValue();
    TypedArray attr = context.obtainStyledAttributes(typedValue.data,
            new int[]{R.attr.colorPrimary, R.attr.colorPrimaryDark});
    if (attr != null) {
        if (prevState.toolbarColor > 0) {
            prevState.toolbarColor = attr.getColor(0, 0);
        }
        @StyleableRes int index = 1;
        prevState.statusBarColor = attr.getColor(index, prevState.toolbarColor);
        attr.recycle();
    }

    if (toolbar.getTitle() != null) {
        prevState.title = toolbar.getTitle().toString();
    }

    if (toolbar.getSubtitle() != null) {
        prevState.subTitle = toolbar.getSubtitle().toString();
    }

    prevState.title = prevState.title != null ? prevState.title : EMPTY;
    prevState.subTitle = prevState.subTitle != null ? prevState.subTitle : EMPTY;

    prevState.logo = toolbar.getLogo();
    prevState.navigationIcon = toolbar.getNavigationIcon();


    return prevState;
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:36,代码来源:MultiMode.java

示例2: Builder

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
public Builder(@NonNull Toolbar toolbar, @NonNull Activity activity) {
    this.toolbar = toolbar;
    this.activity = activity;
    if (toolbar.getBackground() != null) {
        toolbarColor = ((ColorDrawable) (toolbar.getBackground())).getColor();
    }
    this.navigationIcon = toolbar.getNavigationIcon();
    this.logo = toolbar.getLogo();

    this.title = " " + activity.getApplicationContext().getString(R.string.items_selected);
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:12,代码来源:MultiMode.java

示例3: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    // programmatically set theme before super.onCreate()
    mSpec = SelectionSpec.getInstance();
    setTheme(mSpec.themeId);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_matisse);

    if (mSpec.needOrientationRestriction()) {
        setRequestedOrientation(mSpec.orientation);
    }

    if (mSpec.capture) {
        mMediaStoreCompat = new MediaStoreCompat(this);
        if (mSpec.captureStrategy == null)
            throw new RuntimeException("Don't forget to set CaptureStrategy.");
        mMediaStoreCompat.setCaptureStrategy(mSpec.captureStrategy);
    }

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(true);
    Drawable navigationIcon = toolbar.getNavigationIcon();
    TypedArray ta = getTheme().obtainStyledAttributes(new int[]{R.attr.album_element_color});
    int color = ta.getColor(0, 0);
    ta.recycle();
    navigationIcon.setColorFilter(color, PorterDuff.Mode.SRC_IN);

    mButtonPreview = (TextView) findViewById(R.id.button_preview);
    mButtonApply = (TextView) findViewById(R.id.button_apply);
    mButtonPreview.setOnClickListener(this);
    mButtonApply.setOnClickListener(this);
    mContainer = findViewById(R.id.container);
    mEmptyView = findViewById(R.id.empty_view);

    mSelectedCollection.onCreate(savedInstanceState);
    updateBottomToolbar();

    mAlbumsAdapter = new AlbumsAdapter(this, null, false);
    mAlbumsSpinner = new AlbumsSpinner(this);
    mAlbumsSpinner.setOnItemSelectedListener(this);
    mAlbumsSpinner.setSelectedTextView((TextView) findViewById(R.id.selected_album));
    mAlbumsSpinner.setPopupAnchorView(findViewById(R.id.toolbar));
    mAlbumsSpinner.setAdapter(mAlbumsAdapter);
    mAlbumCollection.onCreate(this, this);
    mAlbumCollection.onRestoreInstanceState(savedInstanceState);
    mAlbumCollection.loadAlbums();
}
 
开发者ID:sathishmscict,项目名称:Matisse-Image-and-Video-Selector,代码行数:52,代码来源:MatisseActivity.java

示例4: ToolbarCompatDelegate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
ToolbarCompatDelegate(Toolbar toolbar) {
    mToolbar = toolbar;
    mDefaultUpIndicator = toolbar.getNavigationIcon();
    mDefaultContentDescription = toolbar.getNavigationContentDescription();
}
 
开发者ID:PSD-Company,项目名称:duo-navigation-drawer,代码行数:6,代码来源:DuoDrawerToggle.java

示例5: ToolbarCompatDelegate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
ToolbarCompatDelegate(Toolbar toolbar) {
    this.mToolbar = toolbar;
    this.mDefaultUpIndicator = toolbar.getNavigationIcon();
    this.mDefaultContentDescription = toolbar.getNavigationContentDescription();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:6,代码来源:ActionBarDrawerToggle.java

示例6: onSelectorModeEnter

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
public void onSelectorModeEnter() {
    final Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setActivated(true);
    toolbar.animate().translationY(0.0f).start();

    if (theme.darkStatusBarIconsInSelectorMode()) {
        Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
    } else {
        Util.setLightStatusBarIcons(findViewById(R.id.root_view));
    }

    ColorDrawable statusBarOverlay = getStatusBarOverlay();
    if (statusBarOverlay != null) {
        ColorFade.fadeDrawableAlpha(statusBarOverlay, 0);
    }

    handleMenuVisibilityForSelectorMode(true);

    if (!pick_photos) {
        ColorFade.fadeBackgroundColor(toolbar, toolbarColor, accentColor);

        ColorFade.fadeToolbarTitleColor(toolbar, accentTextColor, null);

        //fade overflow menu icon
        ColorFade.fadeDrawableColor(toolbar.getOverflowIcon(), textColorSecondary, accentTextColor);

        Drawable navIcon = toolbar.getNavigationIcon();
        if (navIcon instanceof Animatable) {
            ((Animatable) navIcon).start();
            ColorFade.fadeDrawableColor(navIcon, textColorSecondary, accentTextColor);
        }
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Drawable d;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    AnimatedVectorDrawable drawable = (AnimatedVectorDrawable)
                            ContextCompat.getDrawable(AlbumActivity.this,
                                    R.drawable.cancel_to_back_avd);
                    //mutating avd to reset it
                    drawable.mutate();
                    d = drawable;
                } else {
                    d = ContextCompat.getDrawable(AlbumActivity.this,
                            R.drawable.ic_clear_black_24dp);
                }
                d = DrawableCompat.wrap(d);
                DrawableCompat.setTint(d.mutate(), accentTextColor);
                toolbar.setNavigationIcon(d);
            }
        }, navIcon instanceof Animatable ? (int) (500 * Util.getAnimatorSpeed(this)) : 0);
    } else {
        toolbar.setBackgroundColor(accentColor);
        toolbar.setTitleTextColor(accentTextColor);
    }

    if (!pick_photos) {
        animateFab(true, false);
    }
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:62,代码来源:AlbumActivity.java

示例7: onSelectorModeEnter

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
public void onSelectorModeEnter() {
    fileOpIntent = null;

    final Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setActivated(true);
    toolbar.animate().translationY(0.0f).start();

    if (theme.darkStatusBarIconsInSelectorMode()) {
        Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
    } else {
        Util.setLightStatusBarIcons(findViewById(R.id.root_view));
    }

    ColorDrawable statusBarOverlay = getStatusBarOverlay();
    if (statusBarOverlay != null) {
        ColorFade.fadeDrawableAlpha(statusBarOverlay, 0);
    }

    ColorFade.fadeBackgroundColor(toolbar, toolbarColor, accentColor);

    ColorFade.fadeToolbarTitleColor(toolbar, accentTextColor, null);

    //fade overflow menu icon
    ColorFade.fadeDrawableColor(toolbar.getOverflowIcon(),
            textColorSecondary, accentTextColor);

    Drawable navIcon = toolbar.getNavigationIcon();
    if (navIcon instanceof Animatable) {
        ((Animatable) navIcon).start();
        ColorFade.fadeDrawableColor(navIcon,
                textColorSecondary, accentTextColor);
    }
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Drawable d;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                AnimatedVectorDrawable drawable = (AnimatedVectorDrawable)
                        ContextCompat.getDrawable(FileExplorerActivity.this,
                                R.drawable.cancel_to_back_avd);
                //mutating avd to reset it
                drawable.mutate();
                d = drawable;
            } else {
                d = ContextCompat.getDrawable(FileExplorerActivity.this,
                        R.drawable.ic_clear_black_24dp);
            }
            d = DrawableCompat.wrap(d);
            DrawableCompat.setTint(d.mutate(), accentTextColor);
            toolbar.setNavigationIcon(d);

            //make menu items visible
            for (int i = 0; i < menu.size(); i++) {
                MenuItem item = menu.getItem(i);
                switch (item.getItemId()) {
                    case R.id.copy:
                    case R.id.move:
                    case R.id.delete:
                        item.setVisible(true);
                        break;
                    default:
                        item.setVisible(false);
                        break;
                }
            }
        }
    }, navIcon instanceof Animatable ? (int) (500 * Util.getAnimatorSpeed(this)) : 0);
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:70,代码来源:FileExplorerActivity.java


注:本文中的android.support.v7.widget.Toolbar.getNavigationIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。