¡@

Home 

2014/10/16 ¤W¤È 08:12:31

android Programming Glossary: displaymetrics

How do I get the ScreenSize programmatically in android

http://stackoverflow.com/questions/11252067/how-do-i-get-the-screensize-programmatically-in-android

this data about the current device in my java code. The DisplayMetrics only gives information about the current device density. Nothing..

Android - How to make slide menu like facebook, spotify and Google +

http://stackoverflow.com/questions/11465774/android-how-to-make-slide-menu-like-facebook-spotify-and-google

import android.content.Context import android.util.DisplayMetrics import android.view.View import android.view.animation.AlphaAnimation.. FilterAnimation Context context this.context context DisplayMetrics displayMetrics context.getResources .getDisplayMetrics deviceWidth.. DisplayMetrics displayMetrics context.getResources .getDisplayMetrics deviceWidth displayMetrics.widthPixels as my animation is x..

How to maintain multi layers of ImageViews and keep their aspect ratio based on the largest one?

http://stackoverflow.com/questions/16729169/how-to-maintain-multi-layers-of-imageviews-and-keep-their-aspect-ratio-based-on

import android.util.AttributeSet import android.util.DisplayMetrics import android.util.Log import android.util.TypedValue import.. LayeredImageViewResources super getContext .getAssets new DisplayMetrics null @Override public Drawable getDrawable int id throws NotFoundException.. bd BitmapDrawable d bd.getBitmap .setDensity DisplayMetrics.DENSITY_DEFAULT bd.setTargetDensity DisplayMetrics.DENSITY_DEFAULT..

Is there a way to determine android physical screen height in cm or inches?

http://stackoverflow.com/questions/2193457/is-there-a-way-to-determine-android-physical-screen-height-in-cm-or-inches

inches share improve this question Use the following DisplayMetrics dm new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics.. this question Use the following DisplayMetrics dm new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics dm double x..

What is the correct way to specify dimensions in DIP from Java code?

http://stackoverflow.com/questions/2238883/what-is-the-correct-way-to-specify-dimensions-in-dip-from-java-code

this I figured that I have to use property density of DisplayMetrics class but is this a correct way May I rely on this formula being.. way May I rely on this formula being always correct pixels DisplayMetrics.density dip Is there a utility function for the conversion somewhere.. method built called TypedValue.applyDimensions int float DisplayMetrics that does this. Here's how to use it returns the number of pixels..

Incorrect Coordinates From getLocationOnScreen/getLocationInWindow

http://stackoverflow.com/questions/2638342/incorrect-coordinates-from-getlocationonscreen-getlocationinwindow

globalView ... the main view of my activity application DisplayMetrics dm new DisplayMetrics this.getWindowManager .getDefaultDisplay.. main view of my activity application DisplayMetrics dm new DisplayMetrics this.getWindowManager .getDefaultDisplay .getMetrics dm int..

Change language programatically in Android

http://stackoverflow.com/questions/2900023/change-language-programatically-in-android

context.getResources Change locale settings in the app. DisplayMetrics dm res.getDisplayMetrics android.content.res.Configuration conf.. locale settings in the app. DisplayMetrics dm res.getDisplayMetrics android.content.res.Configuration conf res.getConfiguration..

getting the screen density programmatically in android?

http://stackoverflow.com/questions/3166501/getting-the-screen-density-programmatically-in-android

this question You can get info on the display from the DisplayMetrics struct DisplayMetrics metrics getResources .getDisplayMetrics.. can get info on the display from the DisplayMetrics struct DisplayMetrics metrics getResources .getDisplayMetrics Though Android doesn't.. struct DisplayMetrics metrics getResources .getDisplayMetrics Though Android doesn't use a direct pixel mapping it uses a..

How to set margin of ImageView using code, not xml

http://stackoverflow.com/questions/3416087/how-to-set-margin-of-imageview-using-code-not-xml

Custom notification layouts and text colors

http://stackoverflow.com/questions/4867338/custom-notification-layouts-and-text-colors

.getDefaultColor notification_text_size text.getTextSize DisplayMetrics metrics new DisplayMetrics WindowManager systemWM WindowManager.. text.getTextSize DisplayMetrics metrics new DisplayMetrics WindowManager systemWM WindowManager getSystemService Context.WINDOW_SERVICE..

Android: Showing wrong screen resolution

http://stackoverflow.com/questions/5078808/android-showing-wrong-screen-resolution

the screen resolution of android phones using this code DisplayMetrics dm new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics.. of android phones using this code DisplayMetrics dm new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics dm str_ScreenSize..

Multiple screen resolution

http://stackoverflow.com/questions/7156752/multiple-screen-resolution

@Override public void onGlobalLayout DisplayMetrics metrics getResources .getDisplayMetrics int deviceWidth metrics.widthPixels.. onGlobalLayout DisplayMetrics metrics getResources .getDisplayMetrics int deviceWidth metrics.widthPixels int deviceHeight metrics.heightPixels..

Determine if the device is a smartphone or tablet?

http://stackoverflow.com/questions/9279111/determine-if-the-device-is-a-smartphone-or-tablet

seems useless for my case this solution work for me now DisplayMetrics metrics new DisplayMetrics getWindowManager .getDefaultDisplay.. this solution work for me now DisplayMetrics metrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics metrics int..

Android - How to make slide menu like facebook, spotify and Google +

http://stackoverflow.com/questions/11465774/android-how-to-make-slide-menu-like-facebook-spotify-and-google

Context context this.context context DisplayMetrics displayMetrics context.getResources .getDisplayMetrics deviceWidth displayMetrics.widthPixels.. context.getResources .getDisplayMetrics deviceWidth displayMetrics.widthPixels as my animation is x axis related so i gets the.. .removeGlobalOnLayoutListener this DisplayMetrics displayMetrics getResources .getDisplayMetrics int deviceWidth displayMetrics.widthPixels..

Is Opengl Development GPU Dependant?

http://stackoverflow.com/questions/17229066/is-opengl-development-gpu-dependant

2 final DisplayMetrics displayMetrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics.. getWindowManager .getDefaultDisplay .getMetrics displayMetrics Set the renderer to our demo renderer defined below. myRenderer.. myGlsurfaceView myGlsurfaceView.setRenderer myRenderer displayMetrics.density myGlsurfaceView.setRenderMode GLSurfaceView.RENDERMODE_CONTINUOUSLY..

Android: how to get value of “listPreferredItemHeight” attribute in code?

http://stackoverflow.com/questions/5982132/android-how-to-get-value-of-listpreferreditemheight-attribute-in-code

to answer. When I run the below code all members of displayMetrics are 0. As is ret . TypedValue value new TypedValue DisplayMetrics.. As is ret . TypedValue value new TypedValue DisplayMetrics displayMetrics new DisplayMetrics Activity context .getTheme .resolveAttribute.. value true float ret value.getDimension displayMetrics android share improve this question This works TypedValue..

Formula px to dp, dp to px android

http://stackoverflow.com/questions/8309354/formula-px-to-dp-dp-to-px-android

pixels and vice versa. This formula px to dp dp int px displayMetrics.densityDpi 160 does not work on small devices because it is.. is divided by zero. This is my dp to px formula px int dp displayMetrics.densityDpi 160 Could someone give me some pointers Thanks in.. question Note The widely used solution above is based on displayMetrics.density . However the docs explain that this value is a rounded..

How do I get the ScreenSize programmatically in android

http://stackoverflow.com/questions/11252067/how-do-i-get-the-screensize-programmatically-in-android

picks between static resources in appropriate folders. I need this data about the current device in my java code. The DisplayMetrics only gives information about the current device density. Nothing is available regarding screen size. I did find the ScreenSize..

Android - How to make slide menu like facebook, spotify and Google +

http://stackoverflow.com/questions/11465774/android-how-to-make-slide-menu-like-facebook-spotify-and-google

package matchat.helpers import com.s3.matchat.R import android.content.Context import android.util.DisplayMetrics import android.view.View import android.view.animation.AlphaAnimation import android.view.animation.Animation import android.view.animation.Animation.AnimationListener.. false private int deviceWidth private int margin public FilterAnimation Context context this.context context DisplayMetrics displayMetrics context.getResources .getDisplayMetrics deviceWidth displayMetrics.widthPixels as my animation is x axis.. public FilterAnimation Context context this.context context DisplayMetrics displayMetrics context.getResources .getDisplayMetrics deviceWidth displayMetrics.widthPixels as my animation is x axis related so i gets the device width and will use that width..

How to maintain multi layers of ImageViews and keep their aspect ratio based on the largest one?

http://stackoverflow.com/questions/16729169/how-to-maintain-multi-layers-of-imageviews-and-keep-their-aspect-ratio-based-on

import android.graphics.drawable.Drawable import android.net.Uri import android.util.AttributeSet import android.util.DisplayMetrics import android.util.Log import android.util.TypedValue import android.view.animation.Animation import android.view.animation.AnimationUtils.. class LayeredImageViewResources extends Resources public LayeredImageViewResources super getContext .getAssets new DisplayMetrics null @Override public Drawable getDrawable int id throws NotFoundException Drawable d super.getDrawable id if d instanceof.. d super.getDrawable id if d instanceof BitmapDrawable BitmapDrawable bd BitmapDrawable d bd.getBitmap .setDensity DisplayMetrics.DENSITY_DEFAULT bd.setTargetDensity DisplayMetrics.DENSITY_DEFAULT return d and how it can be used final LayeredImageView..

Is there a way to determine android physical screen height in cm or inches?

http://stackoverflow.com/questions/2193457/is-there-a-way-to-determine-android-physical-screen-height-in-cm-or-inches

in the Android API for this android screen resolution inches share improve this question Use the following DisplayMetrics dm new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics dm double x Math.pow dm.widthPixels dm.xdpi 2 double.. API for this android screen resolution inches share improve this question Use the following DisplayMetrics dm new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics dm double x Math.pow dm.widthPixels dm.xdpi 2 double y Math.pow dm.heightPixels..

What is the correct way to specify dimensions in DIP from Java code?

http://stackoverflow.com/questions/2238883/what-is-the-correct-way-to-specify-dimensions-in-dip-from-java-code

specify dimensions in DIPs. What is the correct way to calculate this I figured that I have to use property density of DisplayMetrics class but is this a correct way May I rely on this formula being always correct pixels DisplayMetrics.density dip Is there.. density of DisplayMetrics class but is this a correct way May I rely on this formula being always correct pixels DisplayMetrics.density dip Is there a utility function for the conversion somewhere in Android android layout dip share improve this.. share improve this question There is an existing utility method built called TypedValue.applyDimensions int float DisplayMetrics that does this. Here's how to use it returns the number of pixels for 123.4dip int value int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP..

Incorrect Coordinates From getLocationOnScreen/getLocationInWindow

http://stackoverflow.com/questions/2638342/incorrect-coordinates-from-getlocationonscreen-getlocationinwindow

the height of the status notification bar like so View globalView ... the main view of my activity application DisplayMetrics dm new DisplayMetrics this.getWindowManager .getDefaultDisplay .getMetrics dm int topOffset dm.heightPixels globalView.getMeasuredHeight.. the status notification bar like so View globalView ... the main view of my activity application DisplayMetrics dm new DisplayMetrics this.getWindowManager .getDefaultDisplay .getMetrics dm int topOffset dm.heightPixels globalView.getMeasuredHeight View..

Change language programatically in Android

http://stackoverflow.com/questions/2900023/change-language-programatically-in-android

you still need this again i don't recommend that Resources res context.getResources Change locale settings in the app. DisplayMetrics dm res.getDisplayMetrics android.content.res.Configuration conf res.getConfiguration conf.locale new Locale language_code.toLowerCase.. i don't recommend that Resources res context.getResources Change locale settings in the app. DisplayMetrics dm res.getDisplayMetrics android.content.res.Configuration conf res.getConfiguration conf.locale new Locale language_code.toLowerCase res.updateConfiguration..

getting the screen density programmatically in android?

http://stackoverflow.com/questions/3166501/getting-the-screen-density-programmatically-in-android

the screen dpi of the current device android share improve this question You can get info on the display from the DisplayMetrics struct DisplayMetrics metrics getResources .getDisplayMetrics Though Android doesn't use a direct pixel mapping it uses.. current device android share improve this question You can get info on the display from the DisplayMetrics struct DisplayMetrics metrics getResources .getDisplayMetrics Though Android doesn't use a direct pixel mapping it uses a handful of quantized.. this question You can get info on the display from the DisplayMetrics struct DisplayMetrics metrics getResources .getDisplayMetrics Though Android doesn't use a direct pixel mapping it uses a handful of quantized Density Independent Pixel values then scales..

How to set margin of ImageView using code, not xml

http://stackoverflow.com/questions/3416087/how-to-set-margin-of-imageview-using-code-not-xml

Custom notification layouts and text colors

http://stackoverflow.com/questions/4867338/custom-notification-layouts-and-text-colors

szText notification_text_color text.getTextColors .getDefaultColor notification_text_size text.getTextSize DisplayMetrics metrics new DisplayMetrics WindowManager systemWM WindowManager getSystemService Context.WINDOW_SERVICE systemWM.getDefaultDisplay.. text.getTextColors .getDefaultColor notification_text_size text.getTextSize DisplayMetrics metrics new DisplayMetrics WindowManager systemWM WindowManager getSystemService Context.WINDOW_SERVICE systemWM.getDefaultDisplay .getMetrics metrics..

Android: Showing wrong screen resolution

http://stackoverflow.com/questions/5078808/android-showing-wrong-screen-resolution

Showing wrong screen resolution I was trying to get the screen resolution of android phones using this code DisplayMetrics dm new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics dm str_ScreenSize dm.widthPixels x dm.heightPixels.. screen resolution I was trying to get the screen resolution of android phones using this code DisplayMetrics dm new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics dm str_ScreenSize dm.widthPixels x dm.heightPixels str_ScreenSize dd x dm.heightPixels..

Multiple screen resolution

http://stackoverflow.com/questions/7156752/multiple-screen-resolution

mLayoutObserver.addOnGlobalLayoutListener new OnGlobalLayoutListener @Override public void onGlobalLayout DisplayMetrics metrics getResources .getDisplayMetrics int deviceWidth metrics.widthPixels int deviceHeight metrics.heightPixels float.. new OnGlobalLayoutListener @Override public void onGlobalLayout DisplayMetrics metrics getResources .getDisplayMetrics int deviceWidth metrics.widthPixels int deviceHeight metrics.heightPixels float widthInPercentage float 280 320 100 float..

Determine if the device is a smartphone or tablet?

http://stackoverflow.com/questions/9279111/determine-if-the-device-is-a-smartphone-or-tablet

and Product android.os.Build.MODEL android.os.Build.PRODUCT seems useless for my case this solution work for me now DisplayMetrics metrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics metrics int width metrics.widthPixels int height.. android.os.Build.PRODUCT seems useless for my case this solution work for me now DisplayMetrics metrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics metrics int width metrics.widthPixels int height metrics.heightPixels if..

Android - How to make slide menu like facebook, spotify and Google +

http://stackoverflow.com/questions/11465774/android-how-to-make-slide-menu-like-facebook-spotify-and-google

private int deviceWidth private int margin public FilterAnimation Context context this.context context DisplayMetrics displayMetrics context.getResources .getDisplayMetrics deviceWidth displayMetrics.widthPixels as my animation is x axis related so i gets.. context this.context context DisplayMetrics displayMetrics context.getResources .getDisplayMetrics deviceWidth displayMetrics.widthPixels as my animation is x axis related so i gets the device width and will use that width so that this sliding menu.. public void onGlobalLayout filterLayout.getViewTreeObserver .removeGlobalOnLayoutListener this DisplayMetrics displayMetrics getResources .getDisplayMetrics int deviceWidth displayMetrics.widthPixels int filterLayoutWidth deviceWidth 80 100 here..

Is Opengl Development GPU Dependant?

http://stackoverflow.com/questions/17229066/is-opengl-development-gpu-dependant

Request an OpenGL ES 2.0 compatible context. myGlsurfaceView.setEGLContextClientVersion 2 final DisplayMetrics displayMetrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics displayMetrics Set the renderer to our demo renderer.. 2 final DisplayMetrics displayMetrics new DisplayMetrics getWindowManager .getDefaultDisplay .getMetrics displayMetrics Set the renderer to our demo renderer defined below. myRenderer new MyRenderer this myGlsurfaceView myGlsurfaceView.setRenderer.. our demo renderer defined below. myRenderer new MyRenderer this myGlsurfaceView myGlsurfaceView.setRenderer myRenderer displayMetrics.density myGlsurfaceView.setRenderMode GLSurfaceView.RENDERMODE_CONTINUOUSLY MyGLSurfaceView.java in this im getting the..

Android: how to get value of “listPreferredItemHeight” attribute in code?

http://stackoverflow.com/questions/5982132/android-how-to-get-value-of-listpreferreditemheight-attribute-in-code

value true EDIT More code added in response to answer. When I run the below code all members of displayMetrics are 0. As is ret . TypedValue value new TypedValue DisplayMetrics displayMetrics new DisplayMetrics Activity context .getTheme.. I run the below code all members of displayMetrics are 0. As is ret . TypedValue value new TypedValue DisplayMetrics displayMetrics new DisplayMetrics Activity context .getTheme .resolveAttribute android.R.attr.listPreferredItemHeight value true float.. context .getTheme .resolveAttribute android.R.attr.listPreferredItemHeight value true float ret value.getDimension displayMetrics android share improve this question This works TypedValue value new TypedValue Activity context .getTheme .resolveAttribute..

Formula px to dp, dp to px android

http://stackoverflow.com/questions/8309354/formula-px-to-dp-dp-to-px-android

to calculate a variable amount of pixels to density independent pixels and vice versa. This formula px to dp dp int px displayMetrics.densityDpi 160 does not work on small devices because it is divided by zero. This is my dp to px formula px int dp displayMetrics.densityDpi.. 160 does not work on small devices because it is divided by zero. This is my dp to px formula px int dp displayMetrics.densityDpi 160 Could someone give me some pointers Thanks in advance. Kind regards Bram android formula dip share improve.. Kind regards Bram android formula dip share improve this question Note The widely used solution above is based on displayMetrics.density . However the docs explain that this value is a rounded value used with the screen 'buckets'. Eg. on my Nexus 10..