Java Code Examples for android.support.v7.app.ActionBar.setBackgroundDrawable()

The following are Jave code examples for showing how to use setBackgroundDrawable() of the android.support.v7.app.ActionBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: MyCalendar   File: LocationListActivity.java   View Source Code Vote up 6 votes
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);
}
 
Example 2
Project: MyCalendar   File: CancelListActivity.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: MyCalendar   File: TeacherListActivity.java   View Source Code Vote up 5 votes
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();

    }
 
Example 4
Project: MyCalendar   File: WeekLessonDetailActivity.java   View Source Code Vote up 5 votes
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();
}
 
Example 5
Project: MyCalendar   File: SettingsActivity.java   View Source Code Vote up 5 votes
/**
 * 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)));
    }
}
 
Example 6
Project: Minitask   File: MainActivity.java   View Source Code Vote up 5 votes
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)));

}
 
Example 7
Project: TaipeiTechRefined   File: CourseDetailActivity.java   View Source Code Vote up 5 votes
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));
}
 
Example 8
Project: ChatExchange-old   File: ActionBarHue.java   View Source Code Vote up 5 votes
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));
            }
        }
    }
}
 
Example 9
Project: ChatExchange-old   File: ActionBarHue.java   View Source Code Vote up 5 votes
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));
            }

        }
    }
}
 
Example 10
Project: TaipeiTechRefined   File: MainActivity.java   View Source Code Vote up 5 votes
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()));
}
 
Example 11
Project: TaipeiTechRefined   File: DonateActivity.java   View Source Code Vote up 5 votes
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));
}
 
Example 12
Project: privacyidea-authenticator   File: AboutActivity.java   View Source Code Vote up 5 votes
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)));
    }
}
 
Example 13
Project: privacyidea-authenticator   File: EnterDetailsActivity.java   View Source Code Vote up 5 votes
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)));
    }
}
 
Example 14
Project: Neuronizer   File: AppbarCustomizer.java   View Source Code Vote up 4 votes
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)));
}
 
Example 15
Project: AndroidThemeChange   File: ThemeUtils.java   View Source Code Vote up 4 votes
public static void setToolbarColor(AppCompatActivity activity, int color){
    ActionBar actionBar=activity.getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(color));
}
 
Example 16
Project: android-titanium-imagecropper   File: CropImageActivity.java   View Source Code Vote up 4 votes
@Override
@SuppressLint("NewApi")
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // set theme first
  Intent intent = getIntent();
  if (intent.hasExtra(Params.ACTIVITY_THEME)) {
  	String theme = intent.getStringExtra(Params.ACTIVITY_THEME);
  	setTheme(Utils.getR(theme));
  }

  setContentView(Utils.getR("layout.crop_image_activity"));

  mCropImageView = (CropImageView) findViewById(Utils.getR("id.cropImageView"));

  Bundle bundle = intent.getBundleExtra(CropImage.CROP_IMAGE_EXTRA_BUNDLE);
  mCropImageUri = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_SOURCE);
  mOptions = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS);

  if (savedInstanceState == null) {
    if (mCropImageUri == null || mCropImageUri.equals(Uri.EMPTY)) {
      if (CropImage.isExplicitCameraPermissionRequired(this)) {
        // request permissions and handle the result in onRequestPermissionsResult()
        requestPermissions(
            new String[] {Manifest.permission.CAMERA},
            CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE);
      } else {
        CropImage.startPickImageActivity(this);
      }
    } else if (CropImage.isReadExternalStoragePermissionsRequired(this, mCropImageUri)) {
      // request permissions and handle the result in onRequestPermissionsResult()
      requestPermissions(
          new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
          CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
    } else {
      // no permissions required or already grunted, can start crop image activity
      mCropImageView.setImageUriAsync(mCropImageUri);
    }
  }

  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    CharSequence title =
        mOptions.activityTitle != null && mOptions.activityTitle.length() > 0
            ? mOptions.activityTitle
            : getResources().getString(Utils.getR("string.crop_image_activity_title"));
    actionBar.setTitle(title);
    actionBar.setDisplayHomeAsUpEnabled(true);
  }

  boolean barColor = intent.hasExtra(Params.STATUS_BAR_COLOR);
  boolean bgColor = intent.hasExtra(Params.BACKGROUND_COLOR);

  if ( (Build.VERSION.SDK_INT >= 21) && (bgColor || barColor) ) {
      Window window = getWindow();
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

      if (barColor) {
          String colorPrimaryDark = intent.getStringExtra(Params.STATUS_BAR_COLOR);
          window.setStatusBarColor(TiConvert.toColor(colorPrimaryDark));
      }

      if (bgColor) {
          String backgroundColor = intent.getStringExtra(Params.BACKGROUND_COLOR);
          window.setBackgroundDrawable(TiConvert.toColorDrawable(backgroundColor));
      }
  }

  if (intent.hasExtra(Params.BAR_COLOR)) {
      String colorPrimary = intent.getStringExtra(Params.BAR_COLOR);
      actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(colorPrimary));
  }
}
 
Example 17
Project: titanium-android-imagepicker   File: ImageViewerActivity.java   View Source Code Vote up 4 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    Intent intent = getIntent();
    imagesAdapter = intent.getExtras().getParcelableArrayList(Defaults.Params.IMAGES);
    
    Defaults.setupInitialValues(getApplicationContext(), intent);
    setupIds();
    setContentView(frame_layout);
    
    isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE;

    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        
        if (!Defaults.STATUS_BAR_COLOR.isEmpty()) {
        	window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR));
        }
        
        window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR));
    }
    
    ActionBar actionBar = getSupportActionBar();
    
    if (!Defaults.BAR_COLOR.isEmpty()) {
    	actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR));
    }
    	
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(Defaults.TITLE);
    
    mRecyclerView = new RecyclerView(TiApplication.getInstance());
    mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mRecyclerView.setLayoutManager(new GridLayoutManager(ImageViewerActivity.this, Defaults.GRID_SIZE));

    FrameLayout frame_container = (FrameLayout) findViewById(frame_layout_id);
    frame_container.addView(mRecyclerView);
    frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR));
    
    adapterSet = new PhotoAdapter(imagesAdapter);
    mRecyclerView.setAdapter(adapterSet);
    
    if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) {
    	mRecyclerView.addItemDecoration(new DividerDecoration());
    }
    
    setupGlideOptions(); // set glide-options to apply on image
}
 
Example 18
Project: JinsMemeBRIDGE-Android   File: MainActivity.java   View Source Code Vote up 4 votes
void updateActionBar(String title, boolean isRev) {
  Log.d("DEBUG", "updateActionBar 0");

  ActionBar target = getSupportActionBar();
  if (target != null) {
    Log.d("DEBUG", "updateActionBar 1");

    target.setTitle(String.format("  %s", title));
    target.setDisplayHomeAsUpEnabled(false);

    target.setDisplayShowHomeEnabled(true);
    target.setDisplayUseLogoEnabled(false);

    if (isRev) {
      target.setBackgroundDrawable(getDrawable(R.color.no0));
    } else {
      target.setBackgroundDrawable(getDrawable(R.color.no4));
    }

    /*
    switch (batteryStatus) {
      case 1:
        if (isRev) {

        } else {
          target.setLogo(R.drawable.connected_caution);
        }
        break;
      case 2:
        if (isRev) {

        } else {
          target.setLogo(R.drawable.connected_30);
        }
        break;
      case 3:
        if (isRev) {

        } else {
          target.setLogo(R.drawable.connected_50);
        }
        break;
      case 4:
        if (isRev) {

        } else {
          target.setLogo(R.drawable.connected_80);
        }
        break;
      case 5:
        if (isRev) {

        } else {
          target.setLogo(R.drawable.connected_full);
        }
        break;
      default:
        if (isRev) {

        } else {
          target.setLogo(R.drawable.not_connected);
        }
        break;
    }
    */
  }
}
 
Example 19
Project: SuperNote   File: ThemeUtils.java   View Source Code Vote up 4 votes
public static void setToolbarColor(ActionBar actionBar, int color){
    actionBar.setBackgroundDrawable(new ColorDrawable(color));
}
 
Example 20
Project: SuperNote   File: ThemeUtils.java   View Source Code Vote up 4 votes
public static void resetToolbarColor(Context context){
    int color=getColorPrimary(context);
    ActionBar actionBar=((AppCompatActivity)context).getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(color));
}