平板电脑和手机中导航抽屉的不同宽度

平板电脑和手机中导航抽屉的不同宽度

问题描述:

我正在尝试为我的一个项目和在这里,提到了以下内容,

I was trying to implement material design for one of my project and here, the following is mentioned,

导航抽屉的最大宽度是标准宽度的5倍 增量(移动设备上为56dp,平板电脑上为64dp).

The maximum width of the nav drawer is 5 times the standard increment (56dp on mobile and 64dp on tablet).

所以我想知道如何为手机和平板电脑的导航抽屉实现这些宽度.我想为手机或平板电脑上的各个设备设置不同的宽度.

So I would like to know how to implement these width for navigation drawer for mobile and tablets. I want to make different width to respective devices, either phone or tablets.

即使也可以使用Java来完成XML,我也想使用XML.

I would love to use XML even if this also can be done using Java.

谢谢.

在项目中创建values-sw600dp文件夹,然后在其中添加dimens.xml文件. 在dimens.xml文件中定义值和values-sw600dp文件夹的宽度

Create values-sw600dp folder in your project and add dimens.xml file in it. Define width in dimens.xml file of both values and values-sw600dp folder

对于值-sw600dp/dimens.xml

For values-sw600dp/dimens.xml

    <resources>
    <dimen name="width">300dp</dimen></resources>

对于values/dimens.xml

For values/dimens.xml

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

以这种方式致电

   android:layout_width="@dimens/width"