【发布时间】:2015-05-30 12:41:09
【问题描述】:
问题:布局在不同设备上相同分辨率屏幕上显示不同。我在 Samsung Galaxy S4 (1080x1920) 和 LG G2 (1080x1920) 上对其进行了测试。分辨率一样,为什么每个设备的布局显示不一样?
我全部都在布局文件夹中,没有其他分辨率的其他布局。
这里是屏幕:
- 三星 Galaxy S4
http://www.image-share.com/ijpg-2963-272.html
- LG G2
http://www.image-share.com/ijpg-2963-271.html
编辑#1
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layoutMain"
tools:mContext="com.test.app.flock.mActivity">
<ImageView
android:id="@+id/imageViewImageBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<View
android:id="@+id/viewBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background01" />
<View
android:id="@+id/viewFingerprint"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fingerprint01"
android:visibility="gone" />
<Button
android:id="@+id/buttonScanning"
android:layout_width="162dp"
android:layout_height="130dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="41dp"
android:background="@android:color/transparent" />
<ImageView
android:id="@+id/imageViewScanner"
android:layout_width="162dp"
android:layout_height="130dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="41dp"
android:src="@drawable/line01"
android:visibility="gone" />
<TextView
android:id="@+id/textViewResult"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="180dp"
android:text="SCANNING"
android:textSize="30sp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:gravity="center"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="112dp"
android:orientation="vertical">
<DigitalClock
android:id="@+id/digitalClock"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="7"
android:textSize="30sp"
android:textColor="@android:color/white"
android:gravity="center"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewDate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="10"
android:text="10 Grudzien 2015"
android:textSize="20sp"
android:textColor="@android:color/white"
android:gravity="center"
android:textStyle="bold" />
</LinearLayout>
【问题讨论】:
-
这与像素的密度有关。但是您应该没有问题,因为您使用 XML 作为 UI 并且您在 DP(密度像素)中给出宽度和高度。
-
布局仅在 S4 上以不同的方式显示。在具有相同屏幕分辨率的其他设备上,一切都很好。那么问题出在哪里?
-
这个问题你解决了吗?我有同样的问题:new.izigo.pt/content/images/IMG_3209.JPG
-
@Patrick,Android 为每个设备报告的screen density 是什么?
-
@Onik 嗨,谢谢!我可以直接从设备界面获取这些信息吗?联想 (gsmarena.com/lenovo_tab3_7-7951.php) 网站说:“600 x 1024 像素,16:9 比例(~170 ppi 密度)”和华为(gsmarena.com/huawei_mediapad_t3_7_0-8635.php)说:“600 x 1024 像素,16:9 比例(~170 ppi 密度) )”。我只发现了区别:7.0 英寸,137.9 cm2(~72.2% 的屏占比)和 7.0 英寸,137.9 cm2(~74.3% 的屏占比)
标签: android android-layout screen-resolution screen-density