曲线显示了连接件6上的设计



我为android做设计。我有几部手机。他们有不同的决心。我有一个分辨率为1440X2560像素的设计。屏幕有三个不同宽度的正方形。宽度为1440像素,xxxhdpi=360 dpi。我有每个布局的宽度。现在,如果我在三星Galaxy Note 4(1440x2560 640 dpi)上运行该应用程序,一切看起来都是应该的。现在,如果我在Nexus 6(1440x2560?dpi)上运行应用程序,图片并不是整个屏幕。我发现nexus6的分辨率介于xxhdpi和xxxhdpi之间。问题是我如何标记屏幕,使其在所有手机上看起来都一样?或者我不应该使用dpi?在此处输入链接描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="60dp"
            android:layout_height="100dp"
            android:background="#ffff2622">
        </LinearLayout>
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="200dp"
            android:layout_height="100dp"
            android:background="#ff42ff20">
        </LinearLayout>
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="#ff4934ff">
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

根据这一点,Nexus 6实际上位于xxhdpixxxhdpi之间,规模约为3.5。我不喜欢@Squonk建议的布局权重,所以我会重新使用维度。

为不同的屏幕宽度创建值文件夹,如values-w320dpvalues-w360dpvalues-w410dp等。在那里,您可以定义不同屏幕宽度的尺寸。

<resources>
    <dimen name="left_column">60dp</dimen>
    <dimen name="middle_column">200dp</dimen>
    <dimen name="right_column">100dp</dimen>
</resources>

在您的xml中,您可以引用layout_width="@dimen/left_column"

我还建议只设置左右列宽,让中间的列宽填满剩余的空间。你可以用RelativeLayout做到这一点。

在我看来,你想创建一个比率为60:200:100(也是3:10:5)的"正方形"。请尝试以下操作以通过layout_weight设置宽度。。。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="0dp"
            android:layout_height="100dp"
            android:layout_weight="3"
            android:background="#ffff2622">
        </LinearLayout>
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="0dp"
            android:layout_height="100dp"
            android:layout_weight="10"
            android:background="#ff42ff20">
        </LinearLayout>
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="0dp"
            android:layout_height="100dp"
            android:layout_weight="5"
            android:background="#ff4934ff">
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

使用CCD_ 9和CCD_。

最新更新