Java Code Examples for android.support.v7.app.AppCompatActivity#obtainStyledAttributes()
The following examples show how to use
android.support.v7.app.AppCompatActivity#obtainStyledAttributes() .
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: ScreenUtil.java From incubator-weex-playground with Apache License 2.0 | 5 votes |
public static int getDisplayHeight(AppCompatActivity activity) { int height = 0; if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) { Point point=new Point(); activity.getWindowManager().getDefaultDisplay().getSize(point); height=point.y; } Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar); if (isSupportSmartBar) { int smartBarHeight = getSmartBarHeight(activity); Log.e(TAG, "smartBarHeight:" + smartBarHeight); height -= smartBarHeight; } if (activity.getSupportActionBar() != null) { int actionbar= activity.getSupportActionBar().getHeight(); if(actionbar==0){ TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize}); actionbar= (int) actionbarSizeTypedArray.getDimension(0,0); } Log.d(TAG, "actionbar:" + actionbar); height -= actionbar; } int status = getStatusBarHeight(activity); Log.d(TAG, "status:" + status); height -= status; Log.d(TAG,"height:"+height); return height; }
Example 2
Source File: MorphyToolbarBuilder.java From morphy-toolbar with MIT License | 5 votes |
MorphyToolbarBuilder(@NonNull AppCompatActivity activity, @NonNull Toolbar toolbar) { this.activity = activity; this.toolbar = toolbar; title = activity.getTitle(); final Resources resources = activity.getResources(); titleColor = resources.getColor(R.color.mt_title_color); subtitleColor = resources.getColor(R.color.mt_subtitle_color); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) statusBarColor = activity.getWindow().getStatusBarColor(); TypedValue typedValue = new TypedValue(); TypedArray a = activity.obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimary}); toolbarColor = a.getColor(0, 0); a.recycle(); toolbarCollapsedHeight = resources.getDimensionPixelSize(R.dimen.mt_toolbar_height); toolbarExpandedHeight = (int) (2.5f * toolbarCollapsedHeight); pictureCollapsedSize = resources.getDimensionPixelSize(R.dimen.mt_toolbar_picture_size_collapsed); pictureExpandedSize = resources.getDimensionPixelSize(R.dimen.mt_toolbar_picture_size_expanded); innerLayoutCollapsedMargins = new int[]{resources.getDimensionPixelSize(R.dimen.mt_toolbar_content_margin_start_collapsed), resources.getDimensionPixelSize(R.dimen.mt_toolbar_content_margin_top_collapsed), resources.getDimensionPixelSize(R.dimen.mt_toolbar_content_margin_end_collapsed), resources.getDimensionPixelSize(R.dimen.mt_toolbar_content_margin_bottom_collapsed)}; innerLayoutExpandedMargins = new int[]{resources.getDimensionPixelSize(R.dimen.mt_toolbar_content_margin_start_expanded), resources.getDimensionPixelSize(R.dimen.mt_toolbar_content_margin_top_expanded), resources.getDimensionPixelSize(R.dimen.mt_toolbar_content_margin_end_expanded), resources.getDimensionPixelSize(R.dimen.mt_toolbar_content_margin_bottom_expanded)}; }
Example 3
Source File: ScreenUtil.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
public static int getDisplayHeight(AppCompatActivity activity) { int height = 0; if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) { Point point=new Point(); activity.getWindowManager().getDefaultDisplay().getSize(point); height=point.y; } Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar); if (isSupportSmartBar) { int smartBarHeight = getSmartBarHeight(activity); Log.e(TAG, "smartBarHeight:" + smartBarHeight); height -= smartBarHeight; } if (activity.getSupportActionBar() != null) { int actionbar= activity.getSupportActionBar().getHeight(); if(actionbar==0){ TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize}); actionbar= (int) actionbarSizeTypedArray.getDimension(0,0); } Log.d(TAG, "actionbar:" + actionbar); height -= actionbar; } int status = getStatusBarHeight(activity); Log.d(TAG, "status:" + status); height -= status; Log.d(TAG,"height:"+height); return height; }
Example 4
Source File: ScreenUtil.java From WeexOne with MIT License | 5 votes |
public static int getDisplayHeight(AppCompatActivity activity) { int height = 0; if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) { Point point=new Point(); activity.getWindowManager().getDefaultDisplay().getSize(point); height=point.y; } Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar); if (isSupportSmartBar) { int smartBarHeight = getSmartBarHeight(activity); Log.e(TAG, "smartBarHeight:" + smartBarHeight); height -= smartBarHeight; } if (activity != null && activity.getSupportActionBar() != null) { int actionbar= activity.getSupportActionBar().getHeight(); if(actionbar==0){ TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize}); actionbar= (int) actionbarSizeTypedArray.getDimension(0,0); } Log.d(TAG, "actionbar:" + actionbar); height -= actionbar; } int status = getStatusBarHeight(activity); Log.d(TAG, "status:" + status); height -= status; Log.d(TAG,"height:"+height); return height; }
Example 5
Source File: ScreenUtil.java From weex with Apache License 2.0 | 5 votes |
public static int getDisplayHeight(AppCompatActivity activity) { int height = 0; if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) { Point point=new Point(); activity.getWindowManager().getDefaultDisplay().getSize(point); height=point.y; } Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar); if (isSupportSmartBar) { int smartBarHeight = getSmartBarHeight(activity); Log.e(TAG, "smartBarHeight:" + smartBarHeight); height -= smartBarHeight; } if (activity.getSupportActionBar() != null) { int actionbar= activity.getSupportActionBar().getHeight(); if(actionbar==0){ TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize}); actionbar= (int) actionbarSizeTypedArray.getDimension(0,0); } Log.d(TAG, "actionbar:" + actionbar); height -= actionbar; } int status = getStatusBarHeight(activity); Log.d(TAG, "status:" + status); height -= status; Log.d(TAG,"height:"+height); return height; }