Android 7英寸平板电脑值文件夹

时间:2015-10-23 15:19:20

标签: android android-resources

我已经检查了我的布局正确,除了1个设备横向模式,我想修复它。

Supporting multiple screens看起来过时了。

600dp: 7“平板电脑( 600x1024 mdpi)。

720dp: 10“平板电脑(720x1280 mdpi, 800x1280 mdpi 等)。

mdpi 中密度(mdpi)屏幕的资源(〜 160dpi )。 (这是基线密度。)

hdpi 高密度(hdpi)屏幕的资源(〜 240dpi )。

我的设备是7英寸平板电脑,分辨率为800 x 1280:SM T235有216 dpi

我想知道如何在横向模式下修复其布局尺寸,而对其他人的影响较小。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/nav_header_height"
    android:background="@drawable/side_nav_bar"
    android:gravity="bottom"
    android:orientation="horizontal"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:theme="@style/ThemeOverlay.AppCompat.Dark">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/top_left" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:text="Tel: "
        android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="123456789" />


</LinearLayout>

imageView应该更接近左边距,而带有“Tel:”的TextView应该更靠近图像。但仅限于横向模式和此设备。 我还有其他要测试的设备:10“相同的分辨率,不应该影响它。

我认为@dimen/activity_horizontal_margin需要通过在/res/values/dimens.xml文件夹中添加一些后缀来更改values。 我已经生成了values-v21values-w820dp

修改 android Studio生成的文件:res / values-w820dp /dimens.xml

<resources>
    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
         (such as screen margins) for screens with more than 820dp of available width. This
         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
    <dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

我不知道为什么从 values-w820dp 获取值,因为我的宽度小于820.我只需要附加 -land

1 个答案:

答案 0 :(得分:1)

您可能忽略了the page tvdpi 限定符。

因此您可以使用特定的dimens.xml:

/res/values-land-tvdpi/dimens.xml

修改

当您使用多个限定符时,这些限定符的顺序应该是table2中的顺序。请参阅:Qualifier Rules