智能手机与平板电脑的不同 XML 值



我正在尝试为我的应用程序imageview height'simageview width's提供不同的XML值。问题是我需要智能手机版本平板电脑版本的高度和宽度的不同值。有没有办法做到这一点?提前谢谢。

您可以在 Android 中使用资源限定符 查看此处

在尺寸文件中定义图像宽度和高度

值/二元.xml

<resources>
    <dimen name="image_width">100dp</dimen>
</resources>

值-SW600DP/DIMENS.xml

<resources>
    <dimen name="image_width">150dp</dimen>
</resources>

在活动/片段 xml 中

<ImageView
     android:width="@dimen/image_width"
     android:height="@dimen/image_height" />

最新更新