有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何为不同屏幕大小的安卓 studio自动调整imageview的大小?

我开始使用安卓 Studio为安卓设备开发应用程序。当我测试应用程序的屏幕大小兼容性时,我注意到ImageView不会自动调整大小

imageview的位置在不同的屏幕尺寸下看起来完全不同。如果屏幕足够小,imageview有时会放在viewscope之外

我浏览了整个互联网,但对于如何使应用程序与大多数屏幕尺寸(不包括平板电脑)兼容,我有点困惑。我去了安卓网站,他们说要使用wrap_内容。但是如果我使用这个,我将无法根据需要调整imageview的高度和宽度

有人知道如何使imageview根据屏幕大小自动调整大小吗

以下是正在发生的事情的图片:

这是应用程序的布局:

This is the layout

这就是我想要的样子(像素3):

enter image description here

但这就是它在较小屏幕(Nexus 5)中的外观:

enter image description here

在Xcode中有一个名为“自动调整大小”的功能,可以自动调整内容大小。安卓 studio有类似的功能吗

这是xml:

<?xml version="1.0" encoding="utf-8"?> <安卓x.constraintlayout.widget.ConstraintLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓" xmlns:app="http://schemas.安卓.com/apk/res-auto" xmlns:tools="http://schemas.安卓.com/tools" 安卓:layout_width="match_parent" 安卓:layout_height="match_parent" tools:context=".MainActivity"> <Button 安卓:id="@+id/resetButton" style="@style/Widget.AppCompat.Button.Borderless.Colored" 安卓:layout_width="wrap_content" 安卓:layout_height="0dp" 安卓:layout_marginStart="32dp" 安卓:layout_marginLeft="32dp" 安卓:layout_marginBottom="56dp" 安卓:background="#F70000" 安卓:text="Undo" 安卓:textColor="#000000" 安卓:textSize="24sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" /> <ImageView 安卓:id="@+id/imageView3" 安卓:layout_width="288dp" 安卓:layout_height="248dp" 安卓:background="#1750DF" 安卓:scaleType="fitXY" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.495" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.685" /> </安卓x.constraintlayout.widget.ConstraintLayout>

提前谢谢


共 (0) 个答案