【问题标题】:Emulator views only show the values from sw320dp?模拟器视图只显示来自 sw320dp 的值?
【发布时间】:2018-12-06 23:58:40
【问题描述】:

我有 5 个具有最小宽度限定符的维度文件夹。

  • sw240dp

    <dimen name="album_size">200.1dp</dimen>
    
  • sw320dp

    <dimen name="album_size">266.7dp</dimen>
    
  • sw480dp

    <dimen name="album_size">400dp</dimen>
    
  • sw600dp(用于平板电脑)

    <dimen name="album_size">501dp</dimen>
    

我在 android 文档中找到的屏幕支持内容

320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a large phone screen ~5" (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).

从 3.7 英寸到 6.0 的所有模拟器仅在 sw320dp 中显示我的dimens.xml 文件中的值。

我希望在不同屏幕尺寸上支持的布局文件

 <android.support.constraint.ConstraintLayout
    android:id="@+id/mSongAlbumCons"
    android:layout_width="@dimen/album_size"
    android:layout_height="@dimen/album_size"
    app:layout_constraintBottom_toTopOf="@id/playerControls"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/mBottomSheet">

    <ImageView
        android:id="@+id/mAlbumArt"
        android:layout_width="@dimen/album_size"
        android:layout_height="@dimen/album_size"
        android:scaleType="fitXY"
        android:src="@drawable/image2" />

</android.support.constraint.ConstraintLayout>

所以是的,我的问题是专辑封面的宽度和高度在 3.7 英寸屏幕上与在 6.0 英寸屏幕上相同。

android 只显示 sw320dp 文件夹中的值的原因是什么?

谢谢,

编辑

对于 sw600dp 来说它工作得很好,仅对于 3.7 - 6.0 的设备它不起作用。

【问题讨论】:

    标签: java android dimensions screen-size android-screen-support


    【解决方案1】:

    请使用这个 gradle。所有设备都支持它

    实现'com.intuit.sdp:sdp-android:1.0.6'

    使用方法:

    android:textSize="@dimen/_16sdp"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多