为什么具有相同物理尺寸和分辨率的设备可能具有不同的密度?
Why devices that have same physical size and resolution may have different density?
我正在华为 MediaPad T5 和三星 Galaxy Tab A 上进行测试。
它们具有相同的财务尺寸(10.1 英寸)和像素数(1920*1200),
问题一:为什么密度不同(2.0和1.5)?密度只取决于财务规模和像素数量,对吧?
问题2:我使用dp给侧边栏(150dp)设置了相同的宽度,为什么它们看起来不一样?
<android.support.v7.widget.RecyclerView
android:id="@+id/fcom_categories"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="@color/white"
android:scrollbars="none"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
华为:
三星:
PS:我在那里打印了显示规格
华为(xhdpi)
2019-03-31 17:37:23.801 15550-15550/com.ristoo I/DisplaySpecifications: displayName = 内置屏幕
2019-03-31 17:38:05.072 15550-15550/com.ristoo I/DisplaySpecifications: width = 1920
2019-03-31 17:38:05.072 15550-15550/com.ristoo I/DisplaySpecifications: height = 1133
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: widthPixels = 1920
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: heightPixels = 1133
2019-03-31 18:13:03.031 16436-16436/com.ristoo I/DisplaySpecifications: density = 2.0
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: densityDpi = 320
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: xdpi = 225.777
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: ydpi = 225.777
2019-03-31 17:38:05.074 15550-15550/com.ristoo I/DisplaySpecifications: screenHeight = 1133
2019-03-31 17:38:05.074 15550-15550/com.ristoo I/DisplaySpecifications: screenWidth = 1920
2019-03-31 17:38:05.074 15550-15550/com.ristoo I/DisplaySpecifications: orientation = 2
三星(hdpi)
2019-03-31 17:40:57.310 24205-24205/com.ristoo I/DisplaySpecifications: displayName = 内置屏幕
2019-03-31 17:40:57.311 24205-24205/com.ristoo I/DisplaySpecifications: width = 1920
2019-03-31 17:40:57.311 24205-24205/com.ristoo I/DisplaySpecifications: height = 1200
2019-03-31 17:40:57.312 24205-24205/com.ristoo I/DisplaySpecifications: widthPixels = 1920
2019-03-31 17:40:57.312 24205-24205/com.ristoo I/DisplaySpecifications: heightPixels = 1200
2019-03-31 18:12:15.386 25654-25654/com.ristoo I/DisplaySpecifications: density = 1.5
2019-03-31 17:40:57.312 24205-24205/com.ristoo I/DisplaySpecifications: densityDpi = 240
2019-03-31 17:40:57.313 24205-24205/com.ristoo I/DisplaySpecifications: xdpi = 225.777
2019-03-31 17:40:57.313 24205-24205/com.ristoo I/DisplaySpecifications: ydpi = 225.77701
2019-03-31 17:40:57.314 24205-24205/com.ristoo I/DisplaySpecifications: screenHeight = 1200
2019-03-31 17:40:57.314 24205-24205/com.ristoo I/DisplaySpecifications: screenWidth = 1920
2019-03-31 17:40:57.314 24205-24205/com.ristoo I/DisplaySpecifications: orientation = 2
选择哪种像素密度桶由制造商决定。例如,在电视或平板电脑等设计为远离您的脸部使用的东西上,它们可能会选择较低的密度,因此物品看起来更大。
因此,尽管 150dp 的项目在所有设备上的尺寸大致相同,但仍会有一些差异。
我正在华为 MediaPad T5 和三星 Galaxy Tab A 上进行测试。 它们具有相同的财务尺寸(10.1 英寸)和像素数(1920*1200),
问题一:为什么密度不同(2.0和1.5)?密度只取决于财务规模和像素数量,对吧?
问题2:我使用dp给侧边栏(150dp)设置了相同的宽度,为什么它们看起来不一样?
<android.support.v7.widget.RecyclerView
android:id="@+id/fcom_categories"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="@color/white"
android:scrollbars="none"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
华为:
三星:
PS:我在那里打印了显示规格
华为(xhdpi)
2019-03-31 17:37:23.801 15550-15550/com.ristoo I/DisplaySpecifications: displayName = 内置屏幕
2019-03-31 17:38:05.072 15550-15550/com.ristoo I/DisplaySpecifications: width = 1920
2019-03-31 17:38:05.072 15550-15550/com.ristoo I/DisplaySpecifications: height = 1133
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: widthPixels = 1920
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: heightPixels = 1133
2019-03-31 18:13:03.031 16436-16436/com.ristoo I/DisplaySpecifications: density = 2.0
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: densityDpi = 320
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: xdpi = 225.777
2019-03-31 17:38:05.073 15550-15550/com.ristoo I/DisplaySpecifications: ydpi = 225.777
2019-03-31 17:38:05.074 15550-15550/com.ristoo I/DisplaySpecifications: screenHeight = 1133
2019-03-31 17:38:05.074 15550-15550/com.ristoo I/DisplaySpecifications: screenWidth = 1920
2019-03-31 17:38:05.074 15550-15550/com.ristoo I/DisplaySpecifications: orientation = 2
三星(hdpi)
2019-03-31 17:40:57.310 24205-24205/com.ristoo I/DisplaySpecifications: displayName = 内置屏幕
2019-03-31 17:40:57.311 24205-24205/com.ristoo I/DisplaySpecifications: width = 1920
2019-03-31 17:40:57.311 24205-24205/com.ristoo I/DisplaySpecifications: height = 1200
2019-03-31 17:40:57.312 24205-24205/com.ristoo I/DisplaySpecifications: widthPixels = 1920
2019-03-31 17:40:57.312 24205-24205/com.ristoo I/DisplaySpecifications: heightPixels = 1200
2019-03-31 18:12:15.386 25654-25654/com.ristoo I/DisplaySpecifications: density = 1.5
2019-03-31 17:40:57.312 24205-24205/com.ristoo I/DisplaySpecifications: densityDpi = 240
2019-03-31 17:40:57.313 24205-24205/com.ristoo I/DisplaySpecifications: xdpi = 225.777
2019-03-31 17:40:57.313 24205-24205/com.ristoo I/DisplaySpecifications: ydpi = 225.77701
2019-03-31 17:40:57.314 24205-24205/com.ristoo I/DisplaySpecifications: screenHeight = 1200
2019-03-31 17:40:57.314 24205-24205/com.ristoo I/DisplaySpecifications: screenWidth = 1920
2019-03-31 17:40:57.314 24205-24205/com.ristoo I/DisplaySpecifications: orientation = 2
选择哪种像素密度桶由制造商决定。例如,在电视或平板电脑等设计为远离您的脸部使用的东西上,它们可能会选择较低的密度,因此物品看起来更大。
因此,尽管 150dp 的项目在所有设备上的尺寸大致相同,但仍会有一些差异。