本文介绍了配售在特定位置的一个点上不同的屏幕密度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要放在特定的位置点上特定size.I的位图800尺寸创建的600位图,并按照当地的一个点,它工作正常上注2,

I want to Place a point on Particular position over a bitmap of particular size.I created the bitmap of 600 by 800 size and place a point according to that and it works fine on note 2,

但是,当我测试了三星S4,位图看起来非常小,一点也没有特别的位置。

But when I tested this on Samsung S4,the bitmap is looking very small and the point is also not in particular position.

请帮我认为是有什么办法让我的位图是根据手机的具体决议和点自动缩放被放置在屏幕上的同一位置。

Please help me to suggest that is there is any way so that my bitmap is automatically scaled according to particular resolution of phones and the point is placed at same position on the screen.

推荐答案

我想我可以帮你。我有这个同样的问题我自己。你需要做的是找到这个新的屏幕多少更大的比你的旧人,首先让你的设备的尺寸,并把它们在widthOfStandardDevice和heightOfStandardDevice.Once你知道新的屏幕多少越大那么你的旧,你会做两个乘法器被乘以一切。现在,你可以说设置位图的大小bitmap_width和bitmap_height。

I think I can help you. I had this same kind of problem myself. What you need to do is find how much larger this new screen is than your old one, by first getting the dimensions of your device and putting them in for widthOfStandardDevice and heightOfStandardDevice.Once you know how much larger the new screen is then your old one, you would make two multipliers to multiply everything by. You can now say set the size of the bitmap to bitmap_width and bitmap_height.

DisplayMetrics displaymetrics =新DisplayMetrics();

DisplayMetrics displaymetrics = new DisplayMetrics();

getWindowManager()getDefaultDisplay()getMetrics(displaymetrics);

getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);

HEIGHT = displaymetrics.heightPixels;

height = displaymetrics.heightPixels;

宽度= displaymetrics.widthPixels;

width = displaymetrics.widthPixels;

浮动widthMultiplier =宽度/ widthOfStandardDevice;

float widthMultiplier = width/widthOfStandardDevice;

浮动heightMultiplier =身高/ heightOfStandardDevice;

float heightMultiplier = height/heightOfStandardDevice;

INT bitmap_width =(INT)(600 * widthMultiplier);

int bitmap_width = (int)(600 * widthMultiplier);

INT bitmap_height =(INT)(800 * heightMultiplier);

int bitmap_height = (int)(800 * heightMultiplier);

这篇关于配售在特定位置的一个点上不同的屏幕密度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 04:40