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

The following examples show how to use android.support.v7.app.ActionBar#setElevation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityHeaderController.java    From MiPushFramework with GNU General Public License v3.0 6 votes vote down vote up
public EntityHeaderController styleActionBar(AppCompatActivity activity) {
    if (activity == null) {
        Log.w(TAG, "No activity, cannot style actionbar.");
        return this;
    }
    final ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar == null) {
        Log.w(TAG, "No actionbar, cannot style actionbar.");
        return this;
    }
    actionBar.setBackgroundDrawable(
            new ColorDrawable(Utils.getColorAttr(activity, R.attr.colorSettings)));
    actionBar.setElevation(0);
    //if (mRecyclerView != null && mLifecycle != null) {
    //    ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
    //}

    return this;
}
 
Example 2
Source File: DrawerActivity.java    From Jager with GNU General Public License v3.0 6 votes vote down vote up
protected void setToolBar () {
	String[] drawerData = getResources ().getStringArray (R.array
			.drawer_items);
	setSupportActionBar (mToolBar);
	ActionBar actionBar = getSupportActionBar ();
	actionBar.setElevation (5);
	switch (getSelfNavDrawerItem ()) {
		case NAVDRAWER_ITEM_TODAYS_PRODUCTS:
			actionBar.setTitle ("Today\'s " + drawerData[0]);
			break;
		case NAVDRAWER_ITEM_COLLECTIONS:
			actionBar.setTitle ("Featured " + drawerData[1]);
			break;
		case NAVDRAWER_ITEM_SETTINGS:
			actionBar.setTitle (drawerData[2]);
			break;
		case NAVDRAWER_ITEM_ABOUT:
			actionBar.setTitle (drawerData[3]);
			break;
	}
}
 
Example 3
Source File: StatusBarUtils.java    From AndroidWallet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 去除 ActionBar 阴影
 */
public StatusBarUtils clearActionBarShadow() {
    if (Build.VERSION.SDK_INT >= 21) {
        ActionBar supportActionBar = ((AppCompatActivity) mActivity).getSupportActionBar();
        if (supportActionBar != null) {
            supportActionBar.setElevation(0);
        }
    }
    return this;
}
 
Example 4
Source File: IntroActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
public void clearActionBarShadow() {
    if (Build.VERSION.SDK_INT >= 21) {
        ActionBar supportActionBar = ((AppCompatActivity) this).getSupportActionBar();
        if (supportActionBar != null) {
            supportActionBar.setElevation(0);
        }
    }

}
 
Example 5
Source File: BaseActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
/**
 * 去除 ActionBar 阴影
 */
public void clearActionBarShadow() {
    if (Build.VERSION.SDK_INT >= 21) {
        ActionBar supportActionBar = ((AppCompatActivity) this).getSupportActionBar();
        if (supportActionBar != null) {
            supportActionBar.setElevation(0);
        }
    }

}
 
Example 6
Source File: BaseFragmentActivity.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Configure ActionBar
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setElevation(0);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayShowCustomEnabled(false);

        if (STYLE.getToolBarColor() != 0) {
            actionBar.setBackgroundDrawable(new ColorDrawable(STYLE.getToolBarColor()));
        }
    }

    // Setting basic content
    FrameLayout rootLayout = new FrameLayout(this);
    rootLayout.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    rootLayout.setBackgroundColor(STYLE.getMainBackgroundColor());
    rootLayout.setId(R.id.content_frame);
    setContentView(rootLayout);

    // Setting Background Color
    getWindow().setBackgroundDrawable(new ColorDrawable(STYLE.getMainBackgroundColor()));
}
 
Example 7
Source File: SlidingTabLayout.java    From android-sliderview with MIT License 5 votes vote down vote up
public void attachToActionBar(ActionBar bar) {
    this.bar = bar;
    if (bar != null) {
        bar.setElevation(0);
        barBackground = new ColorDrawable(((ColorDrawable) getBackground()).getColor());
        bar.setBackgroundDrawable(barBackground);
    }
}
 
Example 8
Source File: CollectionActivity.java    From Jager with GNU General Public License v3.0 5 votes vote down vote up
private void setupToolBar () {
	setSupportActionBar (mToolBar);
	ActionBar actionBar = getSupportActionBar ();
	if (actionBar != null) {
		actionBar.setTitle (mCollection.getName ());
		actionBar.setElevation (5);
		actionBar.setDisplayHomeAsUpEnabled (true);
	}
}
 
Example 9
Source File: MainActivity.java    From ScreenShift with Apache License 2.0 5 votes vote down vote up
private void setUpToolbar() {
    showTimeout = false;
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_main);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if(actionBar != null) {
        actionBar.setElevation(getResources().getDimension(R.dimen.toolbar_elevation));
    }
    toolbar.setTitle(R.string.app_name);
    toolbar.setTitleTextColor(Color.WHITE);
    masterSwitch = new SwitchCompat(this);
    masterSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                enableService();
            } else {
                disableService();
            }
        }
    });
    Toolbar.LayoutParams params = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.END;
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        params.setMarginEnd((int) getResources().getDimension(R.dimen.activity_vertical_margin));
    } else {
        params.setMargins(0,0,(int) getResources().getDimension(R.dimen.activity_vertical_margin),0);
    }
    toolbar.addView(masterSwitch, params);
    boolean masterSwitchOn = PreferencesHelper.getBoolPreference(this, KEY_MASTER_SWITCH_ON);
    Log.d("masterSwitchOn", String.valueOf(masterSwitchOn));
    if(masterSwitch.isChecked() == masterSwitchOn){
        if(masterSwitchOn) enableService();
        else disableService();
    } else {
        masterSwitch.setChecked(masterSwitchOn);
    }
    showTimeout = true;
}
 
Example 10
Source File: ActionbarextrasModule.java    From actionbarextras with MIT License 5 votes vote down vote up
/**
 * Sets the Actionbar elevation
 * See http://developer.android.com/reference/android/support/v7/app/ActionBar.html#setElevation(float)
 * 
 * @param Integer -	value
 */
private void handleSetElevation(Object value){
	ActionBar actionBar = getActionBar();

	if (actionBar == null){
		return;
	}
	actionBar.setElevation(TiConvert.toFloat(value));
}
 
Example 11
Source File: StyleUtils.java    From IslamicLibraryAndroid with GNU General Public License v3.0 4 votes vote down vote up
public static void setActionBarElevation(ActionBar actionBar, float elevation) {
    if (SystemUtils.runningOnLollipopOrLater() && actionBar != null) {
        actionBar.setElevation(elevation);
    }
}