本文整理汇总了Java中android.support.v7.app.ActionBar.setBackgroundDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java ActionBar.setBackgroundDrawable方法的具体用法?Java ActionBar.setBackgroundDrawable怎么用?Java ActionBar.setBackgroundDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.ActionBar
的用法示例。
在下文中一共展示了ActionBar.setBackgroundDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initView
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void initView() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
}
mCoordinatorLayout = findViewById(R.id.coordinator);
RecyclerView recyclerView = findViewById(R.id.recycle_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new LocationAdapter(this, new ArrayList<Location>());
@SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
recyclerView.setAdapter(animatorAdapter);
ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(recyclerView);
mView_FABMenu = findViewById(R.id.fab_menu_1);
FloatingActionButton addLocation = findViewById(R.id.fab_action_1);
addLocation.setVisibility(View.VISIBLE);
addLocation.setLabelText(mContext.getResources().getString(R.string.add_location));
addLocation.setOnClickListener(this);
}
示例2: initView
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void initView() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
}
mCoordinatorLayout = findViewById(R.id.coordinator);
RecyclerView recyclerView = findViewById(R.id.recycle_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof DefaultItemAnimator) {
((DefaultItemAnimator) animator).setSupportsChangeAnimations(false);
}
mAdapter = new CancelAdapter(this, new ArrayList<DayLesson>());
@SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
recyclerView.setAdapter(animatorAdapter);
ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(recyclerView);
mView_FABMenu = findViewById(R.id.fab_menu_1);
mView_FABMenu.setVisibility(View.GONE);
}
示例3: initView
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void initView() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
}
mCoordinatorLayout = findViewById(R.id.coordinator);
RecyclerView recyclerView = findViewById(R.id.recycle_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new TeacherAdapter(this, new ArrayList<Teacher>());
@SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
recyclerView.setAdapter(animatorAdapter);
ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(recyclerView);
mView_FABMenu = findViewById(R.id.fab_menu_1);
FloatingActionButton addTeacher = findViewById(R.id.fab_action_1);
addTeacher.setVisibility(View.VISIBLE);
addTeacher.setLabelText(mContext.getResources().getString(R.string.add_teacher));
addTeacher.setOnClickListener(this);
CoordinatorLayout.LayoutParams params =
(CoordinatorLayout.LayoutParams) mView_FABMenu.getLayoutParams();
params.setBehavior(new FloatingActionMenuBehavior());
mView_FABMenu.requestLayout();
}
示例4: initView
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void initView() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
}
mView_Coordinator = findViewById(R.id.coordinator);
mView_SubjectName = findViewById(R.id.week_lesson_detail_subject_name);
mView_SubjectArrow = findViewById(R.id.arrow);
mView_Weekday = findViewById(R.id.week_lesson_detail_weekday);
mView_Repeat = findViewById(R.id.week_lesson_detail_repeat);
mView_Day = findViewById(R.id.week_lesson_detail_day);
mView_FABMenu = findViewById(R.id.fab_menu_1);
FloatingActionButton addDayLesson = findViewById(R.id.fab_action_1);
FloatingActionButton editWeekLesson = findViewById(R.id.fab_action_2);
addDayLesson.setVisibility(View.VISIBLE);
editWeekLesson.setVisibility(View.VISIBLE);
addDayLesson.setLabelText(mResources.getString(R.string.add_day_lesson));
editWeekLesson.setLabelText(mResources.getString(R.string.edit_week_lesson));
editWeekLesson.setImageResource(R.drawable.ic_edit_white_24dp);
RecyclerView mView_RecyclerView = findViewById(R.id.recycle_view);
mView_RecyclerView.setNestedScrollingEnabled(false);
mView_RecyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new DayLessonAdapter(mContext, new ArrayList<DayLesson>(), mColorText, mColorBackground);
@SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, mView_RecyclerView);
mView_RecyclerView.setAdapter(animatorAdapter);
ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(mView_RecyclerView);
registerForContextMenu(mView_SubjectArrow);
mView_SubjectArrow.setOnClickListener(this);
mView_SubjectName.setOnClickListener(this);
addDayLesson.setOnClickListener(this);
editWeekLesson.setOnClickListener(this);
setUpInfo();
}
示例5: setupActionBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
private void setupActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, R.color.color_Actionbar)));
}
}
示例6: applyNewColor
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void applyNewColor (String actionBarColor, String tabStripColor, String indicatorColor) {
ActionBar actionBar = getSupportActionBar();
Window window = this.getWindow();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(actionBarColor)));
window.setStatusBarColor(Color.parseColor(indicatorColor));
tabStrip.setBackground(new ColorDrawable((Color.parseColor(tabStripColor))));
tabStrip.setIndicatorColor(Color.parseColor(indicatorColor));
actionButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(actionBarColor)));
}
示例7: setActionBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
public void setActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
mToolbar.setNavigationOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
actionBar.setTitle(R.string.course_detail_title);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.dark_green)));
}
setStatusBarColor(getResources().getColor(R.color.dark_green));
}
示例8: setActionBarColor
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
public static void setActionBarColor(AppCompatActivity activity, int mAppBarColor)
{
if (mSharedPreferences == null)
{
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
}
if (activity != null)
{
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null)
{
actionBar.setBackgroundDrawable(new ColorDrawable(mAppBarColor));
//Change status bar color too
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
Window window = activity.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(HueUtils.darkenColor(mAppBarColor, 0.7f));
}
}
}
}
示例9: setActionBarColorToSharedPrefsValue
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
public static void setActionBarColorToSharedPrefsValue(AppCompatActivity activity)
{
if (mSharedPreferences == null)
{
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
}
if (activity != null)
{
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null)
{
int initialColor = mSharedPreferences.getInt("default_color", activity.getResources().getColor(R.color.colorPrimary));
actionBar.setBackgroundDrawable(new ColorDrawable(initialColor));
//Change status bar color too
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
Window window = activity.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(HueUtils.darkenColor(initialColor, 0.7f));
}
}
}
}
示例10: setActionBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
public void setActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(currentFragment.getTitleStringId());
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(currentFragment.getTitleColorId())));
}
setStatusBarColor(getResources().getColor(currentFragment.getTitleColorId()));
}
示例11: setActionBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
public void setActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
mToolbar.setNavigationOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
actionBar.setTitle(R.string.donate_text);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.deep_darken)));
}
Utility.setStatusBarColor(this, getResources().getColor(R.color.deep_darken));
}
示例12: setupActionBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void setupActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(PIBLUE)));
}
}
示例13: setupActionBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void setupActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Back button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(PIBLUE)));
}
}
示例14: changeAppbarColor
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
public static void changeAppbarColor(Activity activity, @ColorRes int id) {
ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
if (actionBar != null) actionBar.setBackgroundDrawable(new ColorDrawable(activity.getResources().getColor(id)));
}
示例15: setToolbarColor
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
public static void setToolbarColor(AppCompatActivity activity, int color){
ActionBar actionBar=activity.getSupportActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(color));
}