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

The following examples show how to use android.support.v7.app.ActionBar#getHeight() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: ShaderEditor   File: EditorFragment.java    License: 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
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 3
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 4
Source Project: delion   File: ActionModeController.java    License: 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 5
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 6
/**
 * @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 7
Source Project: WeexOne   File: ScreenUtil.java    License: 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 8
Source Project: weex   File: ScreenUtil.java    License: 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 9
Source Project: 365browser   File: ActionModeController.java    License: 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;
}