Androidアプリを作っていますがGalaxy Tabの仕様で画面サイズは1024x600ですが、このサイズでコンポーネントを追加しようとすると左下が切れてしまいます。
違いを確認するために次のコードを追加しました
WindowManager mWMgr = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
int width = mWMgr.getDefaultDisplay().getWidth();
int height = mWMgr.getDefaultDisplay().getHeight();
Toast.makeText(getApplicationContext(),
"[system][w=" + width + ":h=" + height + "]", Toast.LENGTH_LONG).show();
width = getWindowManager().getDefaultDisplay().getWidth();
height = getWindowManager().getDefaultDisplay().getHeight();
Toast.makeText(getApplicationContext(),
"[this][w=" + width + ":h=" + height + "]", Toast.LENGTH_LONG).show();
実行すると、次のように表示されます: [system][w=600:h=1024] [this][w=400:h=683]
なぜそれが起こるのですか?
必要に応じて、コードを追加してコンポーネントを画面に表示します。
これは私のlayout.xmlです
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:id="@+id/image01" android:layout_width="match_parent"
android:layout_height="match_parent" android:scaleType="fitXY" />
</LinearLayout>
この場合、ImageView に描画した画像は画面サイズ (400x683) にスケーリングされます。
私は以下でテストしました:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="600px"
android:layout_height="1024px">
<ImageView android:id="@+id/image01" android:layout_width="match_parent"
android:layout_height="match_parent" android:scaleType="fitXY" />
</LinearLayout>
すると、画像の左下が画面からはみ出してしまいます。