android Programming Glossary: metrics.widthpixels
Android DisplayMetrics returns incorrect screen size in pixels on ICS http://stackoverflow.com/questions/10991194/android-displaymetrics-returns-incorrect-screen-size-in-pixels-on-ics fullscreenheight metrics.heightPixels int fullscreenwidth metrics.widthPixels and.... Display display getWindowManager .getDefaultDisplay..
Detect 7 inch and 10 inch tablet programmatically http://stackoverflow.com/questions/15055458/detect-7-inch-and-10-inch-tablet-programmatically information required to size the display int widthPixels metrics.widthPixels int heightPixels metrics.heightPixels This will return the absolute..
Change expandable indicator in ExpandableListView http://stackoverflow.com/questions/15501413/change-expandable-indicator-in-expandablelistview .getDefaultDisplay .getMetrics metrics int width metrics.widthPixels mExpandableList ExpandableListView findViewById R.id.expandable_list..
animating the childs of an expandablelistview when collapsing/expanding http://stackoverflow.com/questions/4541287/animating-the-childs-of-an-expandablelistview-when-collapsing-expanding .getDefaultDisplay .getMetrics metrics int screenWidth metrics.widthPixels int heightMeasureSpec MeasureSpec.makeMeasureSpec 0 MeasureSpec.UNSPECIFIED..
Position Video Inside a VideoView http://stackoverflow.com/questions/4619563/position-video-inside-a-videoview the retained ratio measurements to the view int height int metrics.widthPixels 3 float 4 int width metrics.widthPixels mVideoView.setVideoAspect.. int height int metrics.widthPixels 3 float 4 int width metrics.widthPixels mVideoView.setVideoAspect width height So this does the job..
Gallery default item selected is in center [duplicate] http://stackoverflow.com/questions/5404590/gallery-default-item-selected-is-in-center MarginLayoutParams gallery.getLayoutParams mlp.setMargins metrics.widthPixels 2 mlp.topMargin mlp.rightMargin mlp.bottomMargin which goes.. half image width which I actually liked if you replace metrics.widthPixels 2 with metrics.widthPixels 2 YOUR_IMAGE_WIDTH it goes all the.. I actually liked if you replace metrics.widthPixels 2 with metrics.widthPixels 2 YOUR_IMAGE_WIDTH it goes all the way to left edge of the screen..
Scale a view and its layered subviews relatively http://stackoverflow.com/questions/6500156/scale-a-view-and-its-layered-subviews-relatively .getDrawable R.drawables.someImage float scale metrics.widthPixels float image.getIntrinsicWidth Finally I used this scale in a..
Android Expandable list http://stackoverflow.com/questions/6534885/android-expandable-list .getDefaultDisplay .getMetrics metrics width metrics.widthPixels this code for adjusting the group indicator into right side..
Multiple screen resolution http://stackoverflow.com/questions/7156752/multiple-screen-resolution metrics getResources .getDisplayMetrics int deviceWidth metrics.widthPixels int deviceHeight metrics.heightPixels float widthInPercentage..
Get the real screen resolution on Ice Cream Sandwich http://stackoverflow.com/questions/8566322/get-the-real-screen-resolution-on-ice-cream-sandwich .getMetrics metrics height metrics.heightPixels width metrics.widthPixels Log.d SCREEN RES Width width . Height height Here's the output..
Slide down effect on ExpandableListView http://stackoverflow.com/questions/8780292/slide-down-effect-on-expandablelistview .getDefaultDisplay .getMetrics metrics int screenWidth metrics.widthPixels int heightMeasureSpec MeasureSpec.makeMeasureSpec 0 MeasureSpec.UNSPECIFIED..
Android animate drop down/up view proper http://stackoverflow.com/questions/9248930/android-animate-drop-down-up-view-proper .getDefaultDisplay .getMetrics metrics int screenWidth metrics.widthPixels int heightMeasureSpec MeasureSpec.makeMeasureSpec 0 MeasureSpec.UNSPECIFIED..
Samsung Galaxy S2 2.3.5+ not calling overScrollBy() http://stackoverflow.com/questions/9261911/samsung-galaxy-s2-2-3-5-not-calling-overscrollby deltaX deltaY scrollX scrollY scrollRangeX scrollRangeY 0 metrics.widthPixels isTouchEvent On every other device Gingerbread and up of course..
Determine if the device is a smartphone or tablet? http://stackoverflow.com/questions/9279111/determine-if-the-device-is-a-smartphone-or-tablet .getDefaultDisplay .getMetrics metrics int width metrics.widthPixels int height metrics.heightPixels if SharedCode.width 1023 SharedCode.height..
Android DisplayMetrics returns incorrect screen size in pixels on ICS http://stackoverflow.com/questions/10991194/android-displaymetrics-returns-incorrect-screen-size-in-pixels-on-ics getWindowManager .getDefaultDisplay .getMetrics metrics int fullscreenheight metrics.heightPixels int fullscreenwidth metrics.widthPixels and.... Display display getWindowManager .getDefaultDisplay Point size new Point display.getSize size int width size.x int..
Detect 7 inch and 10 inch tablet programmatically http://stackoverflow.com/questions/15055458/detect-7-inch-and-10-inch-tablet-programmatically .getMetrics metrics From this we can get the information required to size the display int widthPixels metrics.widthPixels int heightPixels metrics.heightPixels This will return the absolute value of the width and the height in pixels so 1280x720..
Change expandable indicator in ExpandableListView http://stackoverflow.com/questions/15501413/change-expandable-indicator-in-expandablelistview nice DisplayMetrics metrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics metrics int width metrics.widthPixels mExpandableList ExpandableListView findViewById R.id.expandable_list mExpandableList.setIndicatorBounds width GetPixelFromDips..
animating the childs of an expandablelistview when collapsing/expanding http://stackoverflow.com/questions/4541287/animating-the-childs-of-an-expandablelistview-when-collapsing-expanding metrics new DisplayMetrics activity.getWindowManager .getDefaultDisplay .getMetrics metrics int screenWidth metrics.widthPixels int heightMeasureSpec MeasureSpec.makeMeasureSpec 0 MeasureSpec.UNSPECIFIED int widthMeasureSpec MeasureSpec.makeMeasureSpec..
Position Video Inside a VideoView http://stackoverflow.com/questions/4619563/position-video-inside-a-videoview video and 3 2 screen size. I used the folowing code to give the retained ratio measurements to the view int height int metrics.widthPixels 3 float 4 int width metrics.widthPixels mVideoView.setVideoAspect width height So this does the job but there is an issue.. code to give the retained ratio measurements to the view int height int metrics.widthPixels 3 float 4 int width metrics.widthPixels mVideoView.setVideoAspect width height So this does the job but there is an issue it gives me a 4 3 video with the width..
Gallery default item selected is in center [duplicate] http://stackoverflow.com/questions/5404590/gallery-default-item-selected-is-in-center Gallery ctx.findViewById R.id.gallery MarginLayoutParams mlp MarginLayoutParams gallery.getLayoutParams mlp.setMargins metrics.widthPixels 2 mlp.topMargin mlp.rightMargin mlp.bottomMargin which goes almost to the left edge but there is a bit of slack half.. which goes almost to the left edge but there is a bit of slack half image width which I actually liked if you replace metrics.widthPixels 2 with metrics.widthPixels 2 YOUR_IMAGE_WIDTH it goes all the way to left edge of the screen provided this gallery is displaying.. edge but there is a bit of slack half image width which I actually liked if you replace metrics.widthPixels 2 with metrics.widthPixels 2 YOUR_IMAGE_WIDTH it goes all the way to left edge of the screen provided this gallery is displaying images of same size..
Scale a view and its layered subviews relatively http://stackoverflow.com/questions/6500156/scale-a-view-and-its-layered-subviews-relatively .getMetrics metrics Drawable image context.getResources .getDrawable R.drawables.someImage float scale metrics.widthPixels float image.getIntrinsicWidth Finally I used this scale in a custom ImageView class that loads the overlays to position..
Android Expandable list http://stackoverflow.com/questions/6534885/android-expandable-list expList getExpandableListView metrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics metrics width metrics.widthPixels this code for adjusting the group indicator into right side of the view expList.setIndicatorBounds width GetDipsFromPixel..
Multiple screen resolution http://stackoverflow.com/questions/7156752/multiple-screen-resolution @Override public void onGlobalLayout DisplayMetrics metrics getResources .getDisplayMetrics int deviceWidth metrics.widthPixels int deviceHeight metrics.heightPixels float widthInPercentage float 280 320 100 float heightInPercentage float 300 480 100..
Get the real screen resolution on Ice Cream Sandwich http://stackoverflow.com/questions/8566322/get-the-real-screen-resolution-on-ice-cream-sandwich metrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics metrics height metrics.heightPixels width metrics.widthPixels Log.d SCREEN RES Width width . Height height Here's the output 12 19 20 18 42.012 D SCREEN RES 20752 Width 1196. Height..
Slide down effect on ExpandableListView http://stackoverflow.com/questions/8780292/slide-down-effect-on-expandablelistview metrics new DisplayMetrics activity.getWindowManager .getDefaultDisplay .getMetrics metrics int screenWidth metrics.widthPixels int heightMeasureSpec MeasureSpec.makeMeasureSpec 0 MeasureSpec.UNSPECIFIED int widthMeasureSpec MeasureSpec.makeMeasureSpec..
Android animate drop down/up view proper http://stackoverflow.com/questions/9248930/android-animate-drop-down-up-view-proper metrics new DisplayMetrics activity.getWindowManager .getDefaultDisplay .getMetrics metrics int screenWidth metrics.widthPixels int heightMeasureSpec MeasureSpec.makeMeasureSpec 0 MeasureSpec.UNSPECIFIED int widthMeasureSpec MeasureSpec.makeMeasureSpec..
Samsung Galaxy S2 2.3.5+ not calling overScrollBy() http://stackoverflow.com/questions/9261911/samsung-galaxy-s2-2-3-5-not-calling-overscrollby boolean isTouchEvent ... return super.overScrollBy deltaX deltaY scrollX scrollY scrollRangeX scrollRangeY 0 metrics.widthPixels isTouchEvent On every other device Gingerbread and up of course overScrollBy is being called when the scroller reaches it's..
Determine if the device is a smartphone or tablet? http://stackoverflow.com/questions/9279111/determine-if-the-device-is-a-smartphone-or-tablet for me now DisplayMetrics metrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics metrics int width metrics.widthPixels int height metrics.heightPixels if SharedCode.width 1023 SharedCode.height 1023 code for big screen like tablet else code..
|