List of usage examples for android.view Display getWidth
@Deprecated public int getWidth()
From source file:im.vector.activity.ImageWebViewActivity.java
@SuppressLint("NewApi") private Point getDisplaySize() { Point size = new Point(); WindowManager w = getWindowManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { w.getDefaultDisplay().getSize(size); } else {/*from w w w .j av a 2 s . c o m*/ Display d = w.getDefaultDisplay(); size.x = d.getWidth(); size.y = d.getHeight(); } return size; }
From source file:com.renren.api.connect.android.view.RenrenDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progress = new ProgressDialog(getContext()); progress.requestWindowFeature(Window.FEATURE_NO_TITLE); progress.setMessage("Loading..."); content = new LinearLayout(getContext()); content.setOrientation(LinearLayout.VERTICAL); requestWindowFeature(Window.FEATURE_NO_TITLE); if (this.showTitle) { setUpTitle();//from ww w .j ava 2s . c om } setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); float scale = getContext().getResources().getDisplayMetrics().density; float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }
From source file:com.ztspeech.weibo.sdk.renren.view.RenrenDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progress = new ProgressDialog(getContext(), R.style.mydialog); progress.requestWindowFeature(Window.FEATURE_NO_TITLE); progress.setMessage("..."); progress.setCanceledOnTouchOutside(false); content = new LinearLayout(getContext()); content.setOrientation(LinearLayout.VERTICAL); requestWindowFeature(Window.FEATURE_NO_TITLE); if (this.showTitle) { setUpTitle();//from w w w . j a va 2s . co m } setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); float scale = getContext().getResources().getDisplayMetrics().density; float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }
From source file:com.acrylicgoat.scrumnotes.DailyNotesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dailynotes); aBar = getActionBar();/*from www . j a v a 2 s .c om*/ aBar.setTitle(getString(R.string.app_name)); aBar.setDisplayHomeAsUpEnabled(true); //goals = (EditText) findViewById(R.id.editGoals); note = (EditText) findViewById(R.id.editDaily); Display d = getWindowManager().getDefaultDisplay(); if (isTabletDevice(d, this)) { if (d.getWidth() < d.getHeight()) { //in portrait so give more lines note.setLines(20); } else { note.setLines(11); } } getNotes(); String[] items = getResources().getStringArray(R.array.nav_list); setDrawer(items); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); SimpleAdapter sAdapter = new SimpleAdapter(this, navTitles, R.layout.nav_drawer, from, to); // Set the adapter for the list view //drawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list_item, navTitles)); // Set the list's click listener drawerList.setOnItemClickListener(new DrawerItemClickListener()); drawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ drawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; drawerToggle.setDrawerIndicatorEnabled(true); drawerToggle.syncState(); drawerLayout.setDrawerListener(drawerToggle); aBar.setDisplayHomeAsUpEnabled(true); aBar.setHomeButtonEnabled(true); drawerList.setAdapter(sAdapter); }
From source file:ir.rasen.charsoo.view.widgets.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 a2 s. c om */ 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.setTextColor(Color.parseColor(TAB_HOST_UNSELECTED_TEXT_COLOR)); // get screen size int measuredWidth = 0; int measuredHeight = 0; WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); w.getDefaultDisplay().getSize(size); measuredWidth = size.x; measuredHeight = size.y; } else { Display d = w.getDefaultDisplay(); measuredWidth = d.getWidth(); measuredHeight = d.getHeight(); } textView.setLayoutParams( new ViewGroup.LayoutParams(measuredWidth / tabCount, ViewGroup.LayoutParams.MATCH_PARENT)); 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); return textView; }
From source file:com.appsimobile.appsii.HotspotHelperImpl.java
@Override public void setSwipeLocation(SidebarHotspot hotspot, int localX, int localY, int rawX, int rawY) { WindowManager wm = mWindowManager;// w w w. j a v a 2s. com Display display = wm.getDefaultDisplay(); int width = display.getWidth(); if (mDraggingHotspot) { boolean left = rawX < width / 2; int deltaY = mRawStartDragY - rawY; setSwipeLocationForHotspotDrag(hotspot, localX, deltaY, left); } }
From source file:com.tekinarslan.material.sample.customui.slidingtab.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);/*from w w w . j a v a2 s . c om*/ mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); viewWidth = display.getWidth(); }
From source file:de.cellular.lib.lightlib.ui.fragment.LLRequestingFragment.java
protected void startRotate3dAnimationOut() { // Initialize the animations. Display display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay();//from w ww .j a v a2s . c o m int h2 = display.getHeight() / 2; int w2 = display.getWidth() / 2; Rotate3dAnimation outAnim = new Rotate3dAnimation(0, 90, w2, h2, 0.0f, false); outAnim.setDuration(FLIP_ANIMATION_DURATION_OUT); outAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation _animation) { } @Override public void onAnimationRepeat(Animation _animation) { } @Override public void onAnimationEnd(Animation _animation) { if (getView() != null) getView().setVisibility(View.GONE); } }); Rotate3dAnimation inAnim = new Rotate3dAnimation(-90, 0, w2, h2, 0.0f, false); inAnim.setDuration(FLIP_ANIMATION_DURATION_IN); inAnim.setStartOffset(FLIP_ANIMATION_DURATION_OUT); inAnim.setInterpolator( AnimationUtils.loadInterpolator(getActivity(), android.R.anim.decelerate_interpolator)); outAnim.setInterpolator( AnimationUtils.loadInterpolator(getActivity(), android.R.anim.accelerate_interpolator)); if (getView() != null) getView().startAnimation(outAnim); }
From source file:de.cellular.lib.lightlib.ui.fragment.LLRequestingFragment.java
protected void startRotate3dAnimationIn() { // Initialize the animations. Display display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay();/*from w ww. j a v a2 s . c om*/ int h2 = display.getHeight() / 2; int w2 = display.getWidth() / 2; Rotate3dAnimation outAnim = new Rotate3dAnimation(0, 90, w2, h2, 0.0f, false); outAnim.setDuration(FLIP_ANIMATION_DURATION_OUT); outAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation _animation) { } @Override public void onAnimationRepeat(Animation _animation) { } @Override public void onAnimationEnd(Animation _animation) { if (getView() != null) getView().setVisibility(View.VISIBLE); } }); Rotate3dAnimation inAnim = new Rotate3dAnimation(-90, 0, w2, h2, 0.0f, false); inAnim.setDuration(FLIP_ANIMATION_DURATION_IN); inAnim.setStartOffset(FLIP_ANIMATION_DURATION_OUT); inAnim.setInterpolator( AnimationUtils.loadInterpolator(getActivity(), android.R.anim.decelerate_interpolator)); outAnim.setInterpolator( AnimationUtils.loadInterpolator(getActivity(), android.R.anim.accelerate_interpolator)); if (getView() != null) getView().startAnimation(inAnim); }
From source file:com.pac.performance.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (mWidth == 1 || mHeight == 1) { Display display = getWindowManager().getDefaultDisplay(); mWidth = display.getWidth(); mHeight = display.getHeight();/* w w w. j av a 2s . co m*/ } setContentView(R.layout.activity_main); CPUChange = BatteryChange = AudioChange = VoltageChange = IOChange = MinFreeChange = VMChange = false; mFragments.clear(); mFragmentNames.clear(); // add CPU Fragment mFragments.add(new CPUFragment()); mFragmentNames.add(getString(R.string.cpu)); // add Battery Fragment if (Utils.exist(FAST_CHARGE) || Utils.exist(BLX)) { mFragments.add(new BatteryFragment()); mFragmentNames.add(getString(R.string.battery)); } // add Audio Fragment if (Utils.exist(FAUX_SOUND_CONTROL)) { mFragments.add(new AudioFragment()); mFragmentNames.add(getString(R.string.audio)); } // add Voltage Fragment if (Utils.exist(VoltageHelper.CPU_VOLTAGE) || Utils.exist(VoltageHelper.FAUX_VOLTAGE)) { mFragments.add(new VoltageFragment()); mFragmentNames.add(getString(R.string.voltage)); } // add IO Fragment mFragments.add(new IOFragment()); mFragmentNames.add(getString(R.string.io)); // add MinFree Fragment mFragments.add(new MinFreeFragment()); mFragmentNames.add(getString(R.string.minfree)); // add VM Fragment if (VMHelper.getVMValues().size() == VMHelper.getVMFiles().size()) { mFragments.add(new VMFragment()); mFragmentNames.add(getString(R.string.vm)); } // add Information Fragment mFragments.add(new InformationFragment()); mFragmentNames.add(getString(R.string.information)); Utils.saveString("kernelversion", Utils.getFormattedKernelVersion(), getApplicationContext()); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.fragment_list, mFragmentNames)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1, android.R.id.text1, mFragmentNames), this); if (savedInstanceState == null) { setPerm(); Fragment fragment = new ViewPagerFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); selectItem(0); } }