【发布时间】:2017-08-17 06:01:03
【问题描述】:
我正在尝试支持不同的屏幕尺寸,如指南中所示:https://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts。
我有 5 个不同的可绘制文件夹:
可绘制(图像尺寸 40x48png)
drawable-mdpi(图片尺寸80x96png)
drawable-hdpi(图片尺寸120x144png)
drawable-xhdpi(图片尺寸160x192png)
drawable-xxhdpi(图片大小210x252png)
我的项目包括 5 个不同尺寸的布局文件夹: 300dp、330dp、480dp、600dp、720dp。每个文件夹都有相同的 layout.xml 文件。
我的布局代码:
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_margin="15dp"
android:text="Truuuuu"
android:textColor="#000000"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.39"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/textView2"
android:layout_marginTop="60dp"
android:background="#ffffff"
android:orientation="horizontal"
android:id="@+id/relativeLayout">
<ImageView
android:id="@+id/off50"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:src="@drawable/off50" />
<TextView
android:id="@+id/akcija"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="pewpew!"
android:textSize="20sp"
android:layout_alignTop="@+id/off50"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/off50"
android:textColor="#000000"/>
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/off50"
android:layout_alignParentEnd="true"
android:text="pewpew"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:layout_alignStart="@+id/relativeLayout"
android:layout_below="@+id/relativeLayout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/idk"/>
</RelativeLayout>
我的问题是.. 我确实有不同的图像文件夹和图像文件,对吗?我也制作了布局文件夹。我的文本也没有缩放,例如在 layout-sw720dp 上,我几乎可以阅读文本。
我应该怎么做才能支持文本缩放?为什么图像没有在不同的屏幕尺寸上缩放?
【问题讨论】: