Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 响应图像大小限制_Android_Android Layout_Android Constraintlayout - Fatal编程技术网

Android 响应图像大小限制

Android 响应图像大小限制,android,android-layout,android-constraintlayout,Android,Android Layout,Android Constraintlayout,我有一张照片,里面有五张图片。我的问题是,我想让这些图像的大小有响应性,所以现在不管屏幕的宽度有多小,所有的图像都会显示出来 这是我的xml: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://

我有一张照片,里面有五张图片。我的问题是,我想让这些图像的大小有响应性,所以现在不管屏幕的宽度有多小,所有的图像都会显示出来

这是我的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="55dp"
        android:padding="10dp"
        android:gravity="center"
        android:layout_marginBottom="55dp"
        android:text="This ist the title"
        app:layout_constraintBottom_toTopOf="@id/smartphone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:textAppearance="@style/introductionTitle"/>

    <ImageView
        android:id="@+id/smartphone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        app:srcCompat="@drawable/ic_smartphone"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

    <ImageView
        android:id="@+id/next"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        app:srcCompat="@drawable/ic_next_dark"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toRightOf="@id/smartphone"/>

    <ImageView
        android:id="@+id/shop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        app:srcCompat="@drawable/ic_store"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toRightOf="@id/next"/>

    <ImageView
        android:id="@+id/next2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        app:srcCompat="@drawable/ic_next_dark"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toRightOf="@id/shop"/>

    <ImageView
        android:id="@+id/coffee"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        app:srcCompat="@drawable/ic_coffee"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toRightOf="@id/next2"/>

</android.support.constraint.ConstraintLayout>

您可以设置:

android:layout_width = "0dp";
android:layout_weight = 1;

在所有5个视图中,它们将用相对权重覆盖父视图的布局宽度,在本例中,它们的宽度都相等。

这几乎就是我需要的。这张照片的副作用是,当屏幕变大时,图像之间的距离变大了。发布一张屏幕截图,你不知道到底是什么问题吗?这些图像之间应该没有空间。所以当屏幕很大时,它们应该仍然保持在屏幕中间。但是现在他们可以从屏幕上获得宽度的空间,这样在biggetr屏幕上它看起来会伸展开来。你的“线性布局:宽度”?可以尝试“包装内容”