Java Code Examples for android.util.typedvalue#complexToDimensionPixelSize()
The following examples show how to use
android.util.typedvalue#complexToDimensionPixelSize() .
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: SearchFragment.java From redgram-for-reddit with GNU General Public License v3.0 | 6 votes |
private void setupSwipeContainer(){ //disable it for search fragment searchSwipeContainer.setEnabled(false); searchSwipeContainer.setColorSchemeResources(android.R.color.holo_green_dark, android.R.color.holo_red_dark, android.R.color.holo_blue_dark, android.R.color.holo_orange_dark); TypedValue tv = new TypedValue(); if (getContext().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { int actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getContext().getResources().getDisplayMetrics()); //push it down to the same position as the first item to be loaded searchSwipeContainer.setProgressViewOffset(false, 0 , 50); } }
Example 2
Source File: ScreenShot.java From weex with Apache License 2.0 | 6 votes |
public static int getActionBarHeight(Activity activity) { int actionBarHeight = 0; if(activity.getActionBar()!= null){ actionBarHeight = activity.getActionBar().getHeight(); } if (actionBarHeight != 0) return actionBarHeight; final TypedValue tv = new TypedValue(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (activity.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true)){ actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics()); Log.e("actionBarHeight==",actionBarHeight + "android.support.v7.appcompat.R.attr.actionBarSize"); } else if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)){ actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics()); Log.e("actionBarHeight==",actionBarHeight + "actionBarHeight is android.R.attr.actionBarSize"); } } return actionBarHeight; }
Example 3
Source File: MizLib.java From Mizuu with Apache License 2.0 | 6 votes |
/** * Add a margin with a combined height of the ActionBar and Status bar to the top of a given View contained in a FrameLayout * @param c * @param v */ public static void addActionBarAndStatusBarMargin(Context c, View v, FrameLayout.LayoutParams layoutParams) { int mActionBarHeight = 0, mStatusBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else mActionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme) if (hasKitKat()) mStatusBarHeight = convertDpToPixels(c, 25); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, mActionBarHeight + mStatusBarHeight, 0, 0); params.gravity = layoutParams.gravity; v.setLayoutParams(params); }
Example 4
Source File: BarConfig.java From MNImageBrowser with GNU General Public License v3.0 | 6 votes |
@TargetApi(14) private int getActionBarHeight(Activity activity) { int result = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { View actionBar = activity.getWindow().findViewById(R.id.action_bar_container); if (actionBar != null) { result = actionBar.getMeasuredHeight(); } if (result == 0) { TypedValue tv = new TypedValue(); activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true); result = TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics()); } } return result; }
Example 5
Source File: ViewUnit.java From Tweetin with Apache License 2.0 | 5 votes |
public static int getToolbarHeight(Context context) { TypedValue typedValue = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) { return TypedValue.complexToDimensionPixelSize(typedValue.data, context.getResources().getDisplayMetrics()); } return 0; }
Example 6
Source File: ScreenUtil.java From SweetTips with Apache License 2.0 | 5 votes |
/** * 获取actionbar的像素高度,默认使用android官方兼容包做actionbar兼容 * * @return */ public static int getActionBarHeight(Context context) { int actionBarHeight=0; if(context instanceof AppCompatActivity &&((AppCompatActivity) context).getSupportActionBar()!=null) { Log.d("isAppCompatActivity", "==AppCompatActivity"); actionBarHeight = ((AppCompatActivity) context).getSupportActionBar().getHeight(); }else if(context instanceof Activity && ((Activity) context).getActionBar()!=null) { Log.d("isActivity","==Activity"); actionBarHeight = ((Activity) context).getActionBar().getHeight(); }else if(context instanceof ActivityGroup){ Log.d("ActivityGroup","==ActivityGroup"); if (((ActivityGroup) context).getCurrentActivity() instanceof AppCompatActivity && ((AppCompatActivity) ((ActivityGroup) context).getCurrentActivity()).getSupportActionBar()!=null){ actionBarHeight = ((AppCompatActivity) ((ActivityGroup) context).getCurrentActivity()).getSupportActionBar().getHeight(); }else if (((ActivityGroup) context).getCurrentActivity() instanceof Activity && ((Activity) ((ActivityGroup) context).getCurrentActivity()).getActionBar()!=null){ actionBarHeight = ((Activity) ((ActivityGroup) context).getCurrentActivity()).getActionBar().getHeight(); } } if (actionBarHeight != 0) return actionBarHeight; final TypedValue tv = new TypedValue(); if(context.getTheme().resolveAttribute( android.support.v7.appcompat.R.attr.actionBarSize, tv, true)){ if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); }else { if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); } Log.d("actionBarHeight","===="+actionBarHeight); return actionBarHeight; }
Example 7
Source File: BarUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 获取 ActionBar 高度 * @return ActionBar 高度 */ public static int getActionBarHeight() { TypedValue tv = new TypedValue(); try { if (DevUtils.getContext().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { return TypedValue.complexToDimensionPixelSize(tv.data, Resources.getSystem().getDisplayMetrics()); } } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "getActionBarHeight"); } return 0; }
Example 8
Source File: BarUtils.java From Android-utils with Apache License 2.0 | 5 votes |
/** * Return the action bar's height. * * @return the action bar's height */ public static int getActionBarHeight() { TypedValue tv = new TypedValue(); if (UtilsApp.getApp().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { return TypedValue.complexToDimensionPixelSize( tv.data, UtilsApp.getApp().getResources().getDisplayMetrics() ); } return 0; }
Example 9
Source File: DisplayUtils.java From NestedTouchScrollingLayout with MIT License | 5 votes |
public static int getActionBarHeightPixels(final Context pContext) { final TypedValue typedValue = new TypedValue(); if (pContext != null && pContext.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) { return TypedValue.complexToDimensionPixelSize(typedValue.data, pContext.getResources().getDisplayMetrics()); } return 0; }
Example 10
Source File: MainActivity.java From syncthing-android with Mozilla Public License 2.0 | 5 votes |
/** * Calculating width based on * http://www.google.com/design/spec/patterns/navigation-drawer.html#navigation-drawer-specs. */ private void setOptimalDrawerWidth(View drawerContainer) { int actionBarSize = 0; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarSize = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics()); } ViewGroup.LayoutParams params = drawerContainer.getLayoutParams(); DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); int minScreenWidth = min(displayMetrics.widthPixels, displayMetrics.heightPixels); params.width = min(minScreenWidth - actionBarSize, 5 * actionBarSize); drawerContainer.requestLayout(); }
Example 11
Source File: OtherUtils.java From LLApp with Apache License 2.0 | 5 votes |
public static int getActionBarHeight(Context context) { // int contentTop = activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop(); // //statusBarHeight是上面状态栏的高度 //// int titleBarHeight = contentTop - statusBarHeight; // return contentTop; int actionBarHeight = 0; TypedValue tv = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); } return actionBarHeight; }
Example 12
Source File: ViewHelper.java From WanAndroid with GNU General Public License v3.0 | 5 votes |
public static int getSystemActionBarSize(Context context) { TypedValue tv = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { return TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); } else { return dpToPx(context, 48); } }
Example 13
Source File: AppWidgetProviderInfo.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @hide */ public void updateDimensions(DisplayMetrics displayMetrics) { // Converting complex to dp. minWidth = TypedValue.complexToDimensionPixelSize(minWidth, displayMetrics); minHeight = TypedValue.complexToDimensionPixelSize(minHeight, displayMetrics); minResizeWidth = TypedValue.complexToDimensionPixelSize(minResizeWidth, displayMetrics); minResizeHeight = TypedValue.complexToDimensionPixelSize(minResizeHeight, displayMetrics); }
Example 14
Source File: SystemBarMetrics.java From ShaderEditor with MIT License | 5 votes |
public static int getToolBarHeight(Context context) { TypedValue tv = new TypedValue(); return context.getTheme().resolveAttribute( android.R.attr.actionBarSize, tv, true) ? TypedValue.complexToDimensionPixelSize( tv.data, context.getResources().getDisplayMetrics()) : 0; }
Example 15
Source File: BarConfig.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 5 votes |
@TargetApi(14) private int getActionBarHeight(Context context) { int result = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true); result = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); } return result; }
Example 16
Source File: QuickReturnUtils.java From ChipHellClient with Apache License 2.0 | 5 votes |
public static int getActionBarHeight(Context context) { if (sActionBarHeight != 0) { return sActionBarHeight; } context.getTheme().resolveAttribute(android.R.attr.actionBarSize, sTypedValue, true); sActionBarHeight = TypedValue.complexToDimensionPixelSize(sTypedValue.data, context.getResources().getDisplayMetrics()); return sActionBarHeight; }
Example 17
Source File: MoviesActivity.java From AndroidSchool with Apache License 2.0 | 5 votes |
@NonNull private MoviesAdapter createAdapter() { TypedValue typedValue = new TypedValue(); getResources().getValue(R.dimen.rows_count, typedValue, true); float rowsCount = typedValue.getFloat(); int actionBarHeight = getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true) ? TypedValue.complexToDimensionPixelSize(typedValue.data, getResources().getDisplayMetrics()) : 0; int imageHeight = (int) ((getResources().getDisplayMetrics().heightPixels - actionBarHeight) / rowsCount); int columns = getResources().getInteger(R.integer.columns_count); int imageWidth = getResources().getDisplayMetrics().widthPixels / columns; return new MoviesAdapter(imageHeight, imageWidth, this); }
Example 18
Source File: SystemBarTintManager.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
@TargetApi(14) private int getActionBarHeight(Context context) { int result = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true); result = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); } return result; }
Example 19
Source File: ChromaDoze.java From chromadoze with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mUiState = new UIState(getApplication()); SharedPreferences pref = getSharedPreferences(PREF_NAME, MODE_PRIVATE); mUiState.loadState(pref); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(""); mNavSpinner = (Spinner) findViewById(R.id.nav_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<>( actionBar.getThemedContext(), R.layout.spinner_title, FragmentIndex.getStrings(this)); adapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item); mNavSpinner.setAdapter(adapter); mNavSpinner.setOnItemSelectedListener(this); // Created a scaled-down icon for the Toolbar. { TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.actionBarSize, tv, true); int height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); // This originally used a scaled-down launcher icon, but I don't feel like figuring // out how to render R.mipmap.chromadoze_icon correctly. mToolbarIcon = ContextCompat.getDrawable(this, R.drawable.toolbar_icon); } // When this Activity is first created, set up the initial fragment. // After a save/restore, the framework will drop in the last-used // fragment automatically. if (savedInstanceState == null) { changeFragment(new MainFragment(), false); } }
Example 20
Source File: ScreenUtils.java From YiZhi with Apache License 2.0 | 4 votes |
/** * 获取actionbar的像素高度,默认使用android官方兼容包做actionbar兼容 * * @return */ public static int getActionBarHeight(Context context) { int actionBarHeight = 0; if (context instanceof AppCompatActivity && ((AppCompatActivity) context) .getSupportActionBar() != null) { Log.d("isAppCompatActivity", "==AppCompatActivity"); actionBarHeight = ((AppCompatActivity) context).getSupportActionBar().getHeight(); } else if (context instanceof Activity && ((Activity) context).getActionBar() != null) { Log.d("isActivity", "==Activity"); actionBarHeight = ((Activity) context).getActionBar().getHeight(); } else if (context instanceof ActivityGroup) { Log.d("ActivityGroup", "==ActivityGroup"); if (((ActivityGroup) context).getCurrentActivity() instanceof AppCompatActivity && ( (AppCompatActivity) ((ActivityGroup) context).getCurrentActivity()) .getSupportActionBar() != null) { actionBarHeight = ((AppCompatActivity) ((ActivityGroup) context) .getCurrentActivity()).getSupportActionBar().getHeight(); } else if (((ActivityGroup) context).getCurrentActivity() instanceof Activity && ( (Activity) ((ActivityGroup) context).getCurrentActivity()).getActionBar() != null) { actionBarHeight = ((Activity) ((ActivityGroup) context).getCurrentActivity()) .getActionBar().getHeight(); } } if (actionBarHeight != 0) return actionBarHeight; final TypedValue tv = new TypedValue(); if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr .actionBarSize, tv, true)) { if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr .actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context .getResources().getDisplayMetrics()); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context .getResources().getDisplayMetrics()); } else { if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr .actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context .getResources().getDisplayMetrics()); } Log.d("actionBarHeight", "====" + actionBarHeight); return actionBarHeight; }