0

次の機能を備えたデバイスがあります。

解像度: 1080 x 1920
密度: 480 dpi (xxhdpi)
画面サイズ: 通常
縮尺密度: 3.0

解像度が 960x1440 のビットマップを作成しました。ビットマップにはサイズが 795x150 px の長方形があり、その位置はビットマップ上で X:150 px と Y:900 px です。

ビットマップを drawable-xxhdpi フォルダーに入れました。

レイアウト フォルダー内の私の xml コードは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/loginscreen" >

    <Button
        android:id="@+id/button1"
        android:layout_width="265dp"
        android:layout_height="50dp"
        android:layout_marginLeft="@dimen/login_button_left_margin"
        android:layout_marginTop="@dimen/login_button_top_margin" />

</LinearLayout

次のようなvaluesフォルダー内の私のdimes.xmlファイル:

<resources>

    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="login_button_top_margin">300dp</dimen>
    <dimen name="login_button_left_margin">50dp</dimen>

</resources>

私のデバイスの画面サイズは正常なので、レイアウトと値のフォルダーを試しに使用しました。ボタンがビットマップ上の四角形に重なることを期待していました。しかし、ボタンは長方形の上にあり、ボタンのサイズは長方形のサイズと等しくありません。dp 値は 3 倍にする必要がありますか?

4

1 に答える 1