Дизайн Android приложения

Рейтинг: 0Ответов: 1Опубликовано: 17.12.2014

Здравствуйте, есть дизайн Android приложения в формате psd размеры 1080x1920. Так как макет попадает в класс xxhdpi, при верстке пиксели перевожу в dpi, деля на 3. Явно заданы размеры картинок, однако они не влезают в экран.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="${relativePackage}.${activityClass}" >
<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop"
    android:src="@drawable/bg" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="360dp"
        android:layout_height="45dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/header" >

        <LinearLayout
            android:layout_width="22dp"
            android:layout_height="20dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="17dp"
            android:layout_marginTop="12dp"
            android:background="@drawable/logo" >
        </LinearLayout>

        <TextView
            android:id="@+id/textButer"
            style="@style/buterStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="7dp"
            android:layout_marginTop="7dp"
            android:text="@string/buter" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="309dp"
        android:layout_height="105dp"
        android:layout_below="@+id/linearLayout1"
        android:layout_marginLeft="27dp"
        android:layout_marginRight="25dp"
        android:layout_marginTop="20dp"
        android:paddingLeft="26dp"
        android:paddingRight="29dp"
        android:paddingTop="13dp"
        android:background="@color/whiteRec" >

        <Button
            android:id="@+id/button1"
            android:layout_width="@dimen/sizeGeneralButton"
            android:layout_height="@dimen/sizeGeneralButton"
            android:background="@drawable/recipes" />

        <Button
            android:id="@+id/button2"
            android:layout_width="@dimen/sizeGeneralButton"
            android:layout_height="@dimen/sizeGeneralButton"
            android:layout_marginLeft="26dp"
            android:background="@drawable/multivarka" />

        <Button
            android:id="@+id/button3"
            android:layout_width="@dimen/sizeGeneralButton"
            android:layout_height="@dimen/sizeGeneralButton"
            android:layout_marginLeft="26dp"
            android:background="@drawable/children"/>

    </LinearLayout>

</RelativeLayout>

</RelativeLayout>

Подскажите, как правильно верстать приложение с дизайна psd?

Ответы

▲ 2

DPI не имеет прямого соответствия разрешению. Для определения DPI-категории нужно так же знать физический размер экрана... Кроме того, 1080х1920 имеет соотношение сторон 9х16, экраны устройств же запросто могут иметь другое соотношение (от 1х1 до 1х2, например). Поэтому можно, например, использовать вес (LinearLayout + weight), чтобы разместить элементы пропорционально, или применить ScrollView.