小编Ram*_*ame的帖子

ImageView在Android应用程序的构建中无法在CardView上运行

我正在学习在android studio上为android做一个应用程序,但我遇到了1个问题。我在CardView上添加了ImageView。在预览中,我可以看到ImageView,但是在构建中,我看不到。如何解决?

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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.49"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.51">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:id="@+id/cardView2"
                android:layout_width="393dp"
                android:layout_height="118dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="@+id/cardView"
                app:layout_constraintTop_toBottomOf="@+id/cardView">

                <android.support.constraint.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <ImageView
                        android:id="@+id/imageView4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="3dp"
                        android:layout_marginEnd="220dp"
                        android:adjustViewBounds="true"
                        android:contentDescription="@string/da"
                        android:cropToPadding="true"
                        android:scaleType="fitXY"
                        android:visibility="visible"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"

    tools:srcCompat="@tools:sample/backgrounds/scenic[15]" />

                    <TextView
                        android:id="@+id/textView9"
                        android:layout_width="210dp"
                        android:layout_height="99dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginBottom="8dp"
                        android:fontFamily="serif"
                        android:text="@string/tri"
                        android:textColor="@android:color/background_dark"
                        android:textSize="18sp"
                        android:textStyle="bold"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_bias="0.28"
                        app:layout_constraintStart_toEndOf="@+id/imageView4"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0.65999997" />
                </android.support.constraint.ConstraintLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:id="@+id/cardView"
                android:layout_width="385dp"
                android:layout_height="134dp"
                app:layout_constraintBottom_toTopOf="@+id/cardView2"
                app:layout_constraintEnd_toEndOf="parent" …
Run Code Online (Sandbox Code Playgroud)

android android-imageview android-studio android-cardview

0
推荐指数
1
解决办法
266
查看次数