List of usage examples for android.graphics Point Point
public Point()
From source file:com.cypress.cysmart.CommonFragments.ProfileControlFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Getting the device name and address passed mDeviceNameProfile = getArguments().getString(ARG_DEVICE_NAME); mDeviceAddressProfile = getArguments().getString(ARG_DEVICE_ADDRESS); application = (CySmartApplication) getActivity().getApplication(); // Getting the width of the device Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from www .j a v a2s. c om width = size.x; }
From source file:com.mydatingapp.ui.base.classes.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./* w w w . jav a2 s.c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 2); return textView; }
From source file:com.github.chenxiaolong.dualbootpatcher.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_layout); mHandler = new Handler(); mPrefs = getSharedPreferences("settings", 0); if (savedInstanceState != null) { mTitle = savedInstanceState.getInt(EXTRA_TITLE); }//from www.j av a2s . c o m Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View view) { super.onDrawerClosed(view); if (mPending != null) { mHandler.post(mPending); mPending = null; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } mDrawerView = (NavigationView) findViewById(R.id.left_drawer); mDrawerView.setNavigationItemSelectedListener(this); // There's a weird performance issue when the drawer is first opened, no matter if we set // the background on the nav header RelativeLayout, set the image on an ImageView, or use // Picasso to do either asynchronously. By accident, I noticed that using Picasso's resize() // method with any dimensions (even the original) works around the performance issue. Maybe // something doesn't like PNGs exported from GIMP? View header = mDrawerView.inflateHeaderView(R.layout.nav_header); ImageView navImage = (ImageView) header.findViewById(R.id.nav_header_image); BitmapFactory.Options dimensions = new BitmapFactory.Options(); dimensions.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.drawable.material, dimensions); Picasso.with(this).load(R.drawable.material).resize(dimensions.outWidth, dimensions.outHeight) .into(navImage); // Set nav drawer header text TextView appName = (TextView) header.findViewById(R.id.nav_header_app_name); appName.setText(BuildConfig.APP_NAME_RESOURCE); TextView appVersion = (TextView) header.findViewById(R.id.nav_header_app_version); appVersion.setText(String.format(getString(R.string.version), BuildConfig.VERSION_NAME)); // Nav drawer width according to material design guidelines // http://www.google.com/design/spec/patterns/navigation-drawer.html // https://medium.com/sebs-top-tips/material-navigation-drawer-sizing-558aea1ad266 final Display display = getWindowManager().getDefaultDisplay(); final Point size = new Point(); display.getSize(size); final ViewGroup.LayoutParams params = mDrawerView.getLayoutParams(); int toolbarHeight = getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material); params.width = Math.min(size.x - toolbarHeight, 6 * toolbarHeight); mDrawerView.setLayoutParams(params); if (savedInstanceState != null) { mFragment = savedInstanceState.getInt(EXTRA_FRAGMENT); showFragment(); mDrawerItemSelected = savedInstanceState.getInt(EXTRA_SELECTED_ITEM); } else { String[] initialScreens = getResources().getStringArray(R.array.initial_screen_entry_values); String initialScreen = mPrefs.getString("initial_screen", null); if (initialScreen == null || !ArrayUtils.contains(initialScreens, initialScreen)) { initialScreen = INITIAL_SCREEN_ABOUT; Editor e = mPrefs.edit(); e.putString("initial_screen", initialScreen); e.apply(); } int navId; switch (initialScreen) { case INITIAL_SCREEN_ABOUT: navId = R.id.nav_about; break; case INITIAL_SCREEN_ROMS: navId = R.id.nav_roms; break; case INITIAL_SCREEN_PATCHER: navId = R.id.nav_patch_zip; break; default: throw new IllegalStateException("Invalid initial screen value"); } // Show about screen by default mDrawerItemSelected = navId; } onDrawerItemClicked(mDrawerItemSelected, false); refreshOptionalItems(); // Open drawer on first start new Thread() { @Override public void run() { boolean isFirstStart = mPrefs.getBoolean("first_start", true); if (isFirstStart) { mDrawerLayout.openDrawer(mDrawerView); Editor e = mPrefs.edit(); e.putBoolean("first_start", false); e.apply(); } } }.start(); }
From source file:com.pdftron.pdf.controls.PrintAnnotationsSummaryDialogFragment.java
@Override public void onStart() { super.onStart(); mDialogButton = mDialog.getButton(AlertDialog.BUTTON_POSITIVE); if (Utils.isTablet(getActivity())) { // a hack for shrinking the dialog's width final int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); Window window = mDialog.getWindow(); View view = window.peekDecorView(); if (view != null && Utils.isHoneycombMR2()) { view.measure(spec, spec);//from ww w.j ava 2s . co m int width = 3 * view.getMeasuredWidth() / 2; Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int widthScreen = size.x; if (width < 2 * widthScreen / 3) { mDialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT); } } } updateWidgets(); }
From source file:android.support.v7.view.menu.MenuPopupHelper.java
/** * Creates the popup and assigns cached properties. * * @return an initialized popup// ww w. j av a 2 s . c o m */ @NonNull private MenuPopup createPopup() { final WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); final Display display = windowManager.getDefaultDisplay(); final Point displaySize = new Point(); if (Build.VERSION.SDK_INT >= 17) { display.getRealSize(displaySize); } else if (Build.VERSION.SDK_INT >= 13) { display.getSize(displaySize); } else { displaySize.set(display.getWidth(), display.getHeight()); } final int smallestWidth = Math.min(displaySize.x, displaySize.y); final int minSmallestWidthCascading = mContext.getResources() .getDimensionPixelSize(R.dimen.abc_cascading_menus_min_smallest_width); final boolean enableCascadingSubmenus = smallestWidth >= minSmallestWidthCascading; final MenuPopup popup; if (enableCascadingSubmenus) { popup = new CascadingMenuPopup(mContext, mAnchorView, mPopupStyleAttr, mPopupStyleRes, mOverflowOnly); } else { popup = new StandardMenuPopup(mContext, mMenu, mAnchorView, mPopupStyleAttr, mPopupStyleRes, mOverflowOnly); } // Assign immutable properties. popup.addMenu(mMenu); popup.setOnDismissListener(mInternalOnDismissListener); // Assign mutable properties. These may be reassigned later. popup.setAnchorView(mAnchorView); popup.setCallback(mPresenterCallback); popup.setForceShowIcon(mForceShowIcon); popup.setGravity(mDropDownGravity); return popup; }
From source file:com.facebook.android.friendsmash.GameFragment.java
@SuppressWarnings({ "deprecation" }) @TargetApi(13)/*from w ww. ja v a 2 s . co m*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_game, parent, false); gameFrame = (FrameLayout) v.findViewById(R.id.gameFrame); progressContainer = (FrameLayout) v.findViewById(R.id.progressContainer); smashPlayerNameTextView = (TextView) v.findViewById(R.id.smashPlayerNameTextView); scoreTextView = (TextView) v.findViewById(R.id.scoreTextView); livesContainer = (LinearLayout) v.findViewById(R.id.livesContainer); // Set the progressContainer as invisible by default progressContainer.setVisibility(View.INVISIBLE); // Set the icon width (for the images to be smashed) setIconWidth(getResources().getDimensionPixelSize(R.dimen.icon_width)); // Set the screen dimensions WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (Build.VERSION.SDK_INT >= 13) { Point size = new Point(); display.getSize(size); setScreenWidth(size.x); setScreenHeight(size.y); } else { setScreenWidth(display.getWidth()); setScreenHeight(display.getHeight()); } // Always keep the Action Bar hidden if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActivity().getActionBar().hide(); } // Instantiate the fireImageTask for future fired images fireImageTask = new Runnable() { public void run() { spawnImage(false); } }; // Refresh the score board setScore(getScore()); // Refresh the lives setLives(getLives()); // Note: Images will start firing in the onResume method below return v; }
From source file:com.jimish.material.sample.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w . j av a2s. co m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 3); return textView; }
From source file:com.oldfeel.view.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w .j a v a2s . com */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); int count = mViewPager.getAdapter().getCount(); if (count > 0 && count <= 4) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / count); } return textView; }
From source file:client.smrtms.com.smrtms_client.View.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//www.j ava 2s .c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 3); return textView; }
From source file:com.fisheradelakin.ribbit.utils.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./* ww w.ja va 2 s .c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); // fit tabs to width of screen WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 2); // change number by how many tabs i have return textView; }