Java源码示例:androidx.appcompat.graphics.drawable.DrawerArrowDrawable
示例1
public static Drawable getNavigationIcon(@NonNull Context context, @NonNull CandyBarApplication.NavigationIcon navigationIcon) {
switch (navigationIcon) {
case DEFAULT:
return new DrawerArrowDrawable(context);
case STYLE_1:
return get(context, R.drawable.ic_toolbar_navigation);
case STYLE_2:
return get(context, R.drawable.ic_toolbar_navigation_2);
case STYLE_3:
return get(context, R.drawable.ic_toolbar_navigation_3);
case STYLE_4:
return get(context, R.drawable.ic_toolbar_navigation_4);
default:
return get(context, R.drawable.ic_toolbar_navigation);
}
}
示例2
public ActionBarDrawerToggle(Toolbar toolbar, LockableDrawerLayout drawerLayout,
int openTextId, int closeTextId) {
mDrawable = new DrawerArrowDrawable(toolbar.getContext());
mToolbar = toolbar;
mOpenTextId = openTextId;
mCloseTextId = closeTextId;
drawerLayout.addDrawerListener(this);
toolbar.setNavigationIcon(mDrawable);
toolbar.setNavigationContentDescription(drawerLayout.isDrawerOpen(Gravity.START)
? closeTextId : openTextId);
toolbar.setNavigationOnClickListener((View view) -> {
if (drawerLayout.isDrawerOpen(Gravity.START))
drawerLayout.closeDrawer(Gravity.START, !drawerLayout.isCurrentlyLocked());
else
drawerLayout.openDrawer(Gravity.START, !drawerLayout.isCurrentlyLocked());
drawerLayout.requestLayout();
});
mOpenTextId = openTextId;
mCloseTextId = closeTextId;
}
示例3
@Override
public void onSearchExpanded(boolean expand) {
Toolbar toolbar = findViewById(R.id.toolbar);
mIsMenuVisible = !expand;
if (expand) {
int color = ColorHelper.getAttributeColor(this, R.attr.toolbar_icon);
toolbar.setNavigationIcon(DrawableHelper.getTintedDrawable(
this, R.drawable.ic_toolbar_back, color));
toolbar.setNavigationOnClickListener(view -> onBackPressed());
} else {
SoftKeyboardHelper.closeKeyboard(this);
ColorHelper.setStatusBarColor(this, Color.TRANSPARENT, true);
if (CandyBarApplication.getConfiguration().getNavigationIcon() == CandyBarApplication.NavigationIcon.DEFAULT) {
mDrawerToggle.setDrawerArrowDrawable(new DrawerArrowDrawable(this));
} else {
toolbar.setNavigationIcon(ConfigurationHelper.getNavigationIcon(this,
CandyBarApplication.getConfiguration().getNavigationIcon()));
}
toolbar.setNavigationOnClickListener(view ->
mDrawerLayout.openDrawer(GravityCompat.START));
}
mDrawerLayout.setDrawerLockMode(expand ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED :
DrawerLayout.LOCK_MODE_UNLOCKED);
supportInvalidateOptionsMenu();
}