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

The following examples show how to use android.support.v7.app.ActionBar#getHeight() . 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: EditorFragment.java    From ShaderEditor with MIT License 6 votes vote down vote up
private int getYOffset(Activity activity) {
	if (yOffset == 0) {
		float dp = getResources().getDisplayMetrics().density;

		try {
			ActionBar actionBar = ((AppCompatActivity) activity)
					.getSupportActionBar();

			if (actionBar != null) {
				yOffset = actionBar.getHeight();
			}
		} catch (ClassCastException e) {
			yOffset = Math.round(48f * dp);
		}

		yOffset += Math.round(16f * dp);
	}

	return yOffset;
}
 
Example 2
Source File: SheetSongListController.java    From Musicoco with Apache License 2.0 5 votes vote down vote up
private void calculateRecycleViewHeight() {
    ActionBar bar = ((AppCompatActivity) activity).getSupportActionBar();
    if (bar != null) {
        int actionH = bar.getHeight();
        int randomCH = randomContainer.getHeight();
        int statusH = Utils.getStatusBarHeight(activity);
        int screenHeight = Utils.getMetrics(activity).heightPixels;
        int height = screenHeight - actionH - statusH - randomCH;

        ViewGroup.LayoutParams params = songList.getLayoutParams();
        params.height = height;
        songList.setLayoutParams(params);
    }
}
 
Example 3
Source File: ActionModeController.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @return The current action bar height.
 */
private int queryCurrentActionBarHeight() {
    ActionBar actionBar = mActionBarDelegate.getSupportActionBar();
    if (actionBar != null) return actionBar.getHeight();

    TypedArray styledAttributes =
            mContext.obtainStyledAttributes(new int[] {R.attr.actionBarSize});
    int height = styledAttributes.getDimensionPixelSize(0, 0);
    styledAttributes.recycle();
    return height;
}
 
Example 4
Source File: ScreenUtil.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private static int getSmartBarHeight(AppCompatActivity activity) {
    ActionBar actionbar = activity.getSupportActionBar();
    if (actionbar != null)
        try {
            Class c = Class.forName("com.android.internal.R$dimen");
            Object obj = c.newInstance();
            Field field = c.getField("mz_action_button_min_height");
            int height = Integer.parseInt(field.get(obj).toString());
            return activity.getResources().getDimensionPixelSize(height);
        } catch (Exception e) {
            e.printStackTrace();
            actionbar.getHeight();
        }
    return 0;
}
 
Example 5
Source File: ActionModeController.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return The current action bar height.
 */
private int queryCurrentActionBarHeight() {
    ActionBar actionBar = mActionBarDelegate.getSupportActionBar();
    if (actionBar != null) return actionBar.getHeight();

    TypedArray styledAttributes =
            mContext.obtainStyledAttributes(new int[] {R.attr.actionBarSize});
    int height = styledAttributes.getDimensionPixelSize(0, 0);
    styledAttributes.recycle();
    return height;
}
 
Example 6
Source File: ScreenUtil.java    From WeexOne with MIT License 5 votes vote down vote up
private static int getSmartBarHeight(AppCompatActivity activity) {
    ActionBar actionbar = activity.getSupportActionBar();
    if (actionbar != null)
        try {
            Class c = Class.forName("com.android.internal.R$dimen");
            Object obj = c.newInstance();
            Field field = c.getField("mz_action_button_min_height");
            int height = Integer.parseInt(field.get(obj).toString());
            return activity.getResources().getDimensionPixelSize(height);
        } catch (Exception e) {
            e.printStackTrace();
            actionbar.getHeight();
        }
    return 0;
}
 
Example 7
Source File: ScreenUtil.java    From weex with Apache License 2.0 5 votes vote down vote up
private static int getSmartBarHeight(AppCompatActivity activity) {
    ActionBar actionbar = activity.getSupportActionBar();
    if (actionbar != null)
        try {
            Class c = Class.forName("com.android.internal.R$dimen");
            Object obj = c.newInstance();
            Field field = c.getField("mz_action_button_min_height");
            int height = Integer.parseInt(field.get(obj).toString());
            return activity.getResources().getDimensionPixelSize(height);
        } catch (Exception e) {
            e.printStackTrace();
            actionbar.getHeight();
        }
    return 0;
}
 
Example 8
Source File: ActionModeController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return The current action bar height.
 */
private int queryCurrentActionBarHeight() {
    ActionBar actionBar = mActionBarDelegate.getSupportActionBar();
    if (actionBar != null) return actionBar.getHeight();

    TypedArray styledAttributes =
            mContext.obtainStyledAttributes(new int[] {R.attr.actionBarSize});
    int height = styledAttributes.getDimensionPixelSize(0, 0);
    styledAttributes.recycle();
    return height;
}
 
Example 9
Source File: ScreenUtil.java    From incubator-weex-playground with Apache License 2.0 4 votes vote down vote up
private static int getSmartBarHeight(AppCompatActivity activity) {
    ActionBar actionbar = activity.getSupportActionBar();
    if (actionbar != null)
        try {
            Class c = Class.forName("com.android.internal.R$dimen");
            Object obj = c.newInstance();
            Field field = c.getField("mz_action_button_min_height");
            int height = Integer.parseInt(field.get(obj).toString());
            return activity.getResources().getDimensionPixelSize(height);
        } catch (Exception e) {
            e.printStackTrace();
            actionbar.getHeight();
        }
    return 0;
}