Android ScrollView及其内容使用';包装内容&x27;。如何分配约束优先级?

Android ScrollView及其内容使用';包装内容&x27;。如何分配约束优先级?,android,android-layout,android-scrollview,android-wrap-content,Android,Android Layout,Android Scrollview,Android Wrap Content,我需要一个水平滚动视图,固定高度为100dp,图像视图的动态内容 当前,滚动视图有一个水平线性布局和图像视图s。ImageView的宽度启用了wrap_内容,而所有视图的高度都处于固定高度。ScrollView本身的高度在wrap\u content上 如果ScrollViews内容大于视图在不滚动的情况下可以显示的内容,则ImageViews图像将缩小。ImageViewslayout\u high根据其边界工作,但图像本身不工作 将scaleType更改为其他内容没有帮助。为LinearLa

我需要一个水平
滚动视图
,固定高度为
100dp
,图像视图的动态内容

当前,滚动视图有一个水平
线性布局
图像视图
s。ImageView的宽度启用了
wrap_内容
,而所有视图的高度都处于固定高度。ScrollView本身的高度在
wrap\u content

如果ScrollViews内容大于视图在不滚动的情况下可以显示的内容,则ImageViews图像将缩小。ImageViews
layout\u high
根据其边界工作,但图像本身不工作

scaleType
更改为其他内容没有帮助。为LinearLayout设置固定宽度是可行的,但由于内容应该是动态的,因此这不是一个选项。这似乎是一个默认的用例。这在
xml
中不可能吗

手动指定精确滚动视图宽度的示例

视图看起来像我需要的,但不允许动态内容

宽度在
包裹内容上的示例

图像视图

滚动查看代码如下:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="#CCCCFF">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#AAAAFF"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/so1"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:adjustViewBounds="true"
            android:background="#FF0000"
            android:scaleType="fitCenter"
            android:src="@drawable/so" />

        <Space
            android:layout_width="10dp"
            android:layout_height="match_parent" />

        <ImageView
            android:id="@+id/so2"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:adjustViewBounds="true"
            android:background="#FF0000"
            android:scaleType="fitCenter"
            android:src="@drawable/so" />

        <Space
            android:layout_width="10dp"
            android:layout_height="match_parent" />

        <ImageView
            android:id="@+id/so3"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:adjustViewBounds="true"
            android:background="#FF0000"
            android:scaleType="fitCenter"
            android:src="@drawable/so" />

    </LinearLayout>
</ScrollView>

好的,这比我想象的更容易修复:

ScrollView
s始终垂直。ScrollView中没有方向属性。要获得水平滚动视图,请使用
水平滚动视图
并放弃方向

那么这个

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

应改为:

<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

好的,这比我想象的更容易修复:

ScrollView
s始终垂直。ScrollView中没有方向属性。要获得水平滚动视图,请使用
水平滚动视图
并放弃方向

那么这个

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

应改为:

<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">