表示ズームを変更してAndroid Nの表示サイズの計算に問題があります。あなたが表示ズームを変更することができますAndroidのNで表示サイズを変更してAndroid Nのpxで画面サイズを取得
(チェックhere)
が、ディスプレイサイズ、ユーザはAndroidの設定からズームを設定した場合(...のgetSize()が)変化しませんが...
それを解決するための任意のアイデア?実際の表示サイズにするには、scaledDensityをpx倍したサイズを使用しますか?
私のアプリはdinamically画面サイズを計算するウィンドウとコンポーネントをpxで作成します。コンポーネントはサーバー上に設計されています。デフォルト
:
私はこの問題を抱えている小さなズームを設定した場合
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(sizePoint);
}else{
display.getSize(sizePoint);
}
int smartphoneDisplayWidth = sizePoint.x;
int smartphoneDisplayHeight = sizePoint.y;
int serverDisplayWidth = 720px; //this come from the server
int serverComponentWidth = 720px; //this come from the server
int smartphoneComponentWidth = (smartphoneDisplayWidth/serverDisplayWidth)*serverComponentWidth;
//ex: smartphoneComponentWidth = (1080/720)*720 = 1080; the component widht on the smartphone will be 1080px.
: 簡単に言うと、私は、サーバーとスマートフォンの画面の幅に設定された幅で数学の割合を行います
小さな:
Windowsコンポーネントは、小型にしている。
ピクセルの幅は変更されません、それだけの密度を変更します。
小さな
DisplayMetrics{density=2.2250001, width=1080, height=1813, scaledDensity=2.2250001, xdpi=422.03, ydpi=424.069}
デフォルト
DisplayMetrics{density=2.625, width=1080, height=1794, scaledDensity=2.625, xdpi=422.03, ydpi=424.069}
大
DisplayMetrics{density=2.875, width=1080, height=1782, scaledDensity=2.875, xdpi=422.03, ydpi=424.069}
大きな DisplayMetrics{density=3.125, width=1080, height=1770, scaledDensity=3.125, xdpi=422.03, ydpi=424.069}
最大
DisplayMetrics{density=3.375, width=1080, height=1758, scaledDensity=3.375, xdpi=422.03, ydpi=424.069}
これは解決方法ですか? 'int smartphoneComponentWidth =((smartphoneDisplayWidth * scaledDensity)/ serverDisplayWidth)* serverComponentWidth;' – Giovesoft
Android Nをズームする機能は、アプリケーションの範囲を超えています。さらに、アプリケーションにAndroid Nだけの機能を組み込むと、可能なクライアント数が大幅に制限されます。 –