List of usage examples for android.util TypedValue complexToDimensionPixelSize
public static int complexToDimensionPixelSize(int data, DisplayMetrics metrics)
From source file:com.miz.functions.MizLib.java
/** * Add a padding with a height of the ActionBar to the top of a given View * @param c/* w w w . ja va2 s . c o m*/ * @param v */ public static void addActionBarPadding(Context c, View v) { int mActionBarHeight = 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) v.setPadding(0, mActionBarHeight, 0, 0); }
From source file:com.example.google.walkway.MainActivity.java
private void setSelectedPlace(int index) { Log.d(LOG_TAG, String.format("showSelectedPlace(%d)", index)); // Toggle the selected place in the listview. mPlaceListView.getChildAt(mSelectedPlaceIndex).setSelected(false); mPlaceListView.getChildAt(index).setSelected(true); if (mPlaceViewPager != null) { mPlaceViewPager.setCurrentItem(index); }/*from ww w.j a v a 2 s. c o m*/ // TODO reset the map zoom if details previously displayed // Set the non-selected place markers to a dots. mMarkers[mSelectedPlaceIndex].setIcon(BitmapDescriptorFactory.fromBitmap(getDotMarkerBitmap())); mMarkers[mSelectedPlaceIndex].setAnchor(.5f, .5f); // Replace the currently selected maker with the full marker. float hue = this.getResources().getInteger(R.integer.place_marker_hue); mMarkers[index].setIcon(BitmapDescriptorFactory.defaultMarker(hue)); mMarkers[index].setAnchor(.5f, 1f); // Determine if the marker is in the middle 80% of the map view. LatLng coords = mMarkers[index].getPosition(); Point point = mMap.getProjection().toScreenLocation(coords); View view = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getView(); // XXX dupe code TypedValue tv = new TypedValue(); int actionbarHeight = 0; if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) { actionbarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } // Pad the bottom of the map to accommodate the place viewpager. int viewPagerHeight = 0; if (mPlaceViewPager != null) { viewPagerHeight = mPlaceViewPager.getHeight(); } // XXX end dupe code int width = view.getWidth(); int height = view.getHeight() - viewPagerHeight - actionbarHeight; point.y -= actionbarHeight; if (point.x < .2 * width || point.x > .8 * width || point.y < .2 * height || point.y > .8 * height) { int recenterTime = getResources().getInteger(R.integer.map_recenter_ms); mMap.animateCamera(CameraUpdateFactory.newLatLng(coords), recenterTime, null); } mSelectedPlaceIndex = index; }
From source file:com.nikola.despotoski.drawerlayoutedgetoggle.DrawerLayoutEdgeToggle.java
private int getActionBarHeight() { TypedValue tv = new TypedValue(); int actionBarHeight = 0; if (mActivity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, mActivity.getResources().getDisplayMetrics()); else if (actionBarHeight == 0 && mActivity instanceof ActionBarActivity) { actionBarHeight = (int) mActivity.getResources().getDimension(R.dimen.abc_action_bar_default_height); } else {/*www . j a va2 s.c o m*/ actionBarHeight = iterateAttributesForActionBarSherlock(); } return actionBarHeight; }
From source file:com.miz.functions.MizLib.java
/** * Add a padding with a height of the ActionBar to the bottom of a given View * @param c//from w w w . j a va2s . co m * @param v */ public static void addActionBarPaddingBottom(Context c, View v) { int mActionBarHeight = 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) v.setPadding(0, 0, 0, mActionBarHeight); }
From source file:com.miz.functions.MizLib.java
/** * Add a margin with a height of the ActionBar to the top of a given View contained in a FrameLayout * @param c//from w w w . j a va2 s .c om * @param v */ public static void addActionBarMargin(Context c, View v) { int mActionBarHeight = 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) FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, mActionBarHeight, 0, 0); v.setLayoutParams(params); }
From source file:com.miz.functions.MizLib.java
/** * Add a padding with a combined height of the ActionBar and Status bar to the top of a given View * @param c/*from ww w. j a va 2s .co m*/ * @param v */ public static void addActionBarAndStatusBarPadding(Context c, View v) { 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); v.setPadding(0, mActionBarHeight + mStatusBarHeight, 0, 0); }
From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java
/************************************************************************************ * needed because else the nested preference screen don't have a actionbar/toolbar * * see the fix and the given problem here: http://stackoverflow.com/a/27455363 * ************************************************************************************/ public void setUpNestedScreen(PreferenceScreen preferenceScreen) { final Dialog dialog = preferenceScreen.getDialog(); //ViewGroup list; Toolbar bar;// w w w. jav a 2s .c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { //list = (ViewGroup) dialog.findViewById(android.R.id.list); LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); root.addView(bar, 0); // insert at top } else { ViewGroup root = (ViewGroup) dialog.findViewById(android.R.id.content); ListView content = (ListView) root.getChildAt(0); //list = content; root.removeAllViews(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); int height; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) { height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } else { height = bar.getHeight(); } content.setPadding(0, height, 0, 0); root.addView(content); root.addView(bar); } //list.addView(detailsPrefScreenToAdd.getStatusViewGroup(), 1); //TODO bar.setTitle(preferenceScreen.getTitle()); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogI) { if (AppData.getLoginSuccessful()) { dialogI.dismiss(); } else { showNotConnectedDialog(dialog); } } }); bar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (AppData.getLoginSuccessful()) { dialog.dismiss(); } else { showNotConnectedDialog(dialog); } } }); }
From source file:com.miz.functions.MizLib.java
/** * 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// w w w. j av a 2 s.co m * @param v */ public static void addActionBarAndStatusBarMargin(Context c, View v) { 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); v.setLayoutParams(params); }
From source file:com.miz.functions.MizLib.java
/** * 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//from w w w. j a v a2s .c om * @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); }
From source file:com.cgearc.yummy.Act_Main.java
private int getActionBarHeight() { int actionBarHeight = 0; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }//from ww w . ja v a2 s . co m return actionBarHeight; }