我对布局在 Android 开发中的工作方式有一些想法。
我为具有全高清分辨率的平板电脑(10" Xperia Z1 平板电脑,1920 x 1200)编写了一个应用程序。该应用程序看起来不错,并且在平板电脑上运行良好。该应用程序始终处于横向模式。
当我在分辨率只有一半(1280 x 800)的 4.8 英寸手机上安装相同的应用程序时,我需要指定不同的布局并使用该w<dp>
东西命名文件夹(并更改布局以使其更适合手机)。
药片
所以,对于我认为我应该使用的平板电脑:
layout-w1359dp-land
原因是这样的:
Dpi: 226 ( http://pixeldensitycalculator.com/?h=1920&v=1200&d=10 )
宽度 (px): 1920
计算: 1920 / (226/160) = 1920 / 1,4125 = 1359
电话
而对于电话
layout-w652dp-land
原因是这样的:
Dpi: 314 ( http://pixeldensitycalculator.com/?h=1280&v=800&d=4.8 )
宽度 (px): 1280
计算: 1280 / (314/160) = 1280 / 1,9625= 652
问题
它不工作。它看起来和往常一样糟糕。似乎根本没有考虑到 layout-w652dp-land 。
图像显示了问题,我不明白为什么我在 layout-w652dp-land 文件夹中所做的事情并不重要。
文件夹不被“尊重”的原因可能是什么?
平板电脑视图(一切正常):
** SAMSUNG S3 PHONE VIEW(文件夹名称更改前后)**
编辑
我等待发布 XML,因为我不想让这篇文章太大,而且我不确定它是否与“整体”问题相关,但这里是:
booking_row.xml - 每一行都是这样定义的:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#AAF0F0F0">
<!-- TODO: Update blank fragment layout -->
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
<TableRow
android:id="@+id/booking_row_tablerow"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
android:gravity="center_vertical"
android:background="@android:drawable/list_selector_background"
>
<View
android:id="@+id/booking_row_status_color"
android:layout_width="30dp"
android:background="@android:color/holo_red_dark"></View>
<View
android:id="@+id/View01"
android:layout_width="3px"
android:layout_height="fill_parent"
android:background="#22000000" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:layout_gravity="center" >
<TextView
android:id="@+id/booking_row_tv_time"
android:layout_width="60dp"
android:layout_height="fill_parent"
android:text="13:10"
android:textSize="10sp"
android:layout_column="3"
android:padding="5dp"
android:gravity="center"
/>
</FrameLayout>
<View
android:id="@+id/View01"
android:layout_width="0px"
android:layout_height="0dp"
android:background="#46000000" />
<View
android:id="@+id/View01"
android:layout_width="0px"
android:layout_height="0dp"
android:background="#00ffffff" />
<TextView
android:id="@+id/booking_row_tv_name"
android:layout_width="200dp"
android:text="Test test"
android:textSize="17sp"
android:layout_column="3"
android:padding="5dp" />
<View
android:id="@+id/View01"
android:layout_width="3px"
android:layout_height="fill_parent"
android:background="#22000000" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/booking_row_imageview_direction"
android:layout_column="1"
android:src="@drawable/icon_car_incoming"
android:padding="5dp"
/>
<View
android:id="@+id/View01"
android:layout_width="3px"
android:layout_height="fill_parent"
android:background="#22000000" />
<TextView
android:id="@+id/booking_row_tv_address"
android:layout_width="250dp"
android:text="Some address"
android:textSize="17sp"
android:layout_column="3"
android:padding="5dp" />
<View
android:id="@+id/View01"
android:layout_width="3px"
android:layout_height="fill_parent"
android:background="#22000000" />
<TextView
android:id="@+id/booking_row_tv_delayInfo"
android:layout_width="80dp"
android:text="Info info"
android:textSize="17sp"
android:layout_column="3"
android:padding="5dp" />
<View
android:id="@+id/View01"
android:layout_width="3px"
android:layout_height="fill_parent"
android:background="#22000000" />
<ImageView
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:id="@+id/booking_row_gps_valid"
android:src="@drawable/icon_gps_valid" />
<View
android:id="@+id/View01"
android:layout_width="3px"
android:layout_height="fill_parent"
android:background="#22000000"
android:visibility="gone" />
<TextView
android:id="@+id/booking_row_tv_miscInfo"
android:layout_width="200dp"
android:text="Framplats, ENS"
android:textSize="30sp"
android:layout_column="3"
android:padding="5dp"
android:visibility="gone" />
</TableRow>
</TableLayout>
</FrameLayout>