微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么图片内容未显示在 avd 的 scrollView 中,但显示了滚动条

如何解决为什么图片内容未显示在 avd 的 scrollView 中,但显示了滚动条

我使用了水平滚动视图,在里面我放了一个线性布局,然后是一些图片,但是在 avd 上我看不到图片但是可以看到滚动条。我也可以水平滚动滚动条,唯一的问题是我的图片没有显示

在horizo​​ntalScrollbar里面的xml代码下面:

    tools:context=".MainActivity">

<horizontalscrollview
    android:id="@+id/horizontalscrollview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="112dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

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

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="400dp"
            android:layout_height="402dp"
            android:layout_weight="0"
            android:contentDescription="@string/img3"
            android:visibility="visible"
            tools:srcCompat="@tools:sample/backgrounds/scenic" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="420dp"
            android:layout_height="262dp"
            android:layout_gravity="center"
            android:layout_weight="0"
            android:contentDescription="@string/img"
            tools:srcCompat="@drawable/ic_launcher_background" />

        <ImageView
            android:id="@+id/imageVie3"
            android:layout_width="400dp"
            android:layout_height="260dp"
            android:layout_gravity="center"
            android:layout_weight="0"
            android:contentDescription="@string/img2"
            tools:srcCompat="@drawable/img1" />

    </LinearLayout>
</horizontalscrollview>

解决方法

tools:srcCompat 改为 app:srcCompat

例如

从此:

tools:srcCompat="@tools:sample/backgrounds/scenic"

为此:

app:srcCompat="@tools:sample/backgrounds/scenic"

tools 行仅用于预览和界面构建器。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。