Как определить два разных макета для макетов в одной категории, но с немного разными дюймами?

Я тестирую свой макет в графическом макете eclipse. В графическом виде доступны экраны 5,4 дюйма FWVGA (480x854, mdpi) и 5,1 дюйма WVGA (480x800, mdpi). Если я прав, они оба попадают в категорию больших экранов, поэтому я поместил макет xml в папку layout-large. И я поместил свои изображения в папку drawable-large-mdpi. Но кнопки изображения немного смещены в 5,1-дюймовом WVGA, как вы можете видеть на снимках экрана ниже. Первый 5,1 дюйма, второй скриншот 5,4 дюйма и правильный. 5.1in

5.4in

Мой второй вопрос, который похож на приведенный выше, звучит так. Я сделал новый макет для Nexus 7 и поместил его в папку layout-sw600dp, а изображения — в drawable-tvdpi. Затем я просмотрел этот макет на 7-дюймовом планшете (1024x600, mdpi). И кнопки изображения немного не так, как должно выглядеть. Так же, как и в первом вопросе.

Я понимаю, что причина, вероятно, в том, что 5,1 дюйма и 5,4 дюйма не совсем одинаковы, хотя они попадают в одну и ту же категорию, и у меня должно быть 2 разных макета для них. Итак, как мне поступить? Как я могу иметь два разных макета? Или есть лучшее решение, так как я не хочу создавать макет для каждого размера экрана, который существует на рынке. Вот xml-файл:

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

    <RelativeLayout android:id="@+id/frames_layout"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_marginLeft="73dp" android:layout_marginTop="57dp">

        <ImageView android:id="@+id/fire_frame"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_alignParentLeft="true" android:layout_alignParentTop="true"
            android:background="@drawable/small_fire_icon" />

        <ImageView android:id="@+id/water_frame"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_alignTop="@+id/fire_frame" android:layout_marginLeft="75dp"
            android:layout_toRightOf="@+id/fire_frame" android:background="@drawable/small_water_icon" />

        <ImageView android:id="@+id/earth_frame"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_below="@+id/fire_frame" android:layout_marginTop="71dp"
            android:layout_toLeftOf="@+id/water_frame" android:background="@drawable/small_earth_icon" />

        <ImageView android:id="@+id/wind_frame"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/water_frame" android:layout_alignTop="@+id/earth_frame"
            android:background ="@drawable/small_wind_icon" />
    </RelativeLayout>

        <ImageView android:id="@+id/zoomed_image"
            android:layout_width="wrap_content" android:layout_height="wrap_content" />

    <Button android:id="@+id/frames" android:layout_width="210dp"
        android:layout_height="220dp" android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" android:layout_marginLeft="55dp"
        android:layout_marginTop="30dp" android:onClick="zoomFrames" 
        android:background="@android:color/transparent"/>

    <Button android:id="@+id/blue" android:layout_width="115dp"
        android:layout_height="70dp" android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true" android:layout_marginLeft="220dp"
        android:onClick="zoomImage" 
        android:background="@android:color/transparent"/>

    <Button android:id="@+id/white" android:layout_width="85dp"
        android:layout_height="50dp" android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" android:layout_marginRight="420dp"
        android:layout_marginTop="420dp" android:onClick="zoomImage"
        android:visibility="invisible"
        android:background="@android:color/transparent"/> 
        <ImageView
        android:id="@+id/fireplace"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="311dp"
        android:layout_marginLeft="67dp"
        android:background="@drawable/fire"
     />
            <ImageButton
        android:id="@+id/water_room"
          android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="310dp"
        android:layout_marginLeft="90dp"
        android:background="@drawable/view_water_room"
        android:onClick="finishFireRoom"
                android:visibility="gone"
        />
        <ImageView android:id="@+id/frames_zoomed_image"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:background="@drawable/frames_zoomed" android:onClick="hideZoomedFrames"
        android:visibility="gone"/>

    <RelativeLayout android:id="@+id/frameZoomedLayout"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_marginTop="113dp" android:layout_marginLeft="145dp"
        android:visibility="gone"
        >

        <ImageButton android:id="@+id/fire_icon"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:background="@drawable/fire_icon" android:onClick="changeIcon" />
        <ImageButton android:id="@+id/water_icon"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/fire_icon" android:layout_toRightOf="@+id/fire_icon"
            android:background="@drawable/water_icon" android:layout_marginLeft="147dp" android:onClick="changeIcon"/>
        <ImageButton android:id="@+id/earth_icon"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_below="@+id/fire_icon" android:layout_marginTop="140dp"
            android:layout_toLeftOf="@+id/water_icon" android:background="@drawable/earth_icon" android:onClick="changeIcon"/>

        <ImageButton android:id="@+id/wind_icon"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/water_icon" android:layout_alignTop="@+id/earth_icon"
            android:background="@drawable/wind_icon" android:onClick="changeIcon"/>
    </RelativeLayout>



</RelativeLayout>

person Nazerke    schedule 29.12.2013    source источник


Ответы (1)


первый шаг

второй шаг

третий шагна 3-м шаге задайте все параметры вашего устройства, такие как экран, язык и т. д. и ты готов

person Sush    schedule 29.12.2013
comment
спасибо, я не знал, что вы можете сделать это. Тем не менее, это требует много работы, если я буду делать это для каждого размера экрана. А типов экранов, как известно, несколько десятков. Нужно ли иметь столько копий макета. В моей папке макета у меня есть 27 xmls. И если я буду делать это для каждого экрана, у меня будет более 100 XML-файлов. Как вы думаете, есть ли другие способы сделать это? - person Nazerke; 29.12.2013
comment
не требуется для каждого размера экрана. Разработка пользовательского интерфейса для Android так не пойдет. сначала проверьте на каждом экране, если вы нашли что-то не так, тогда сделайте это. иначе просто установите стандартный дизайн пользовательского интерфейса для одного типа экрана. - person Sush; 29.12.2013