简体   繁体   中英

Android Studio NO image is Seen in Image-Layout over Grid Layout

The code is shared AS

<GridLayout
        android:id="@+id/gridLayout"
        android:layout_width="368dp"
        android:layout_height="368dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/board"
        android:columnCount="3"
        android:rowCount="3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"

            android:tag="0" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"
            android:layout_marginLeft="17dp"

            android:tag="1" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"
            android:layout_marginLeft="12dp"

            android:tag="2" />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"
            android:layout_marginTop="13dp"

            android:tag="3" />

        <ImageView
            android:id="@+id/imageView5"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"
            android:layout_marginLeft="17dp"
            android:layout_marginTop="13dp"

            android:tag="4" />

        <ImageView
            android:id="@+id/imageView6"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"
            android:layout_marginLeft="12dp"
            android:layout_marginTop="13dp"

            android:tag="5" />

        <ImageView
            android:id="@+id/imageView7"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"
            android:layout_marginTop="16dp"

            android:tag="6" />

        <ImageView
            android:id="@+id/imageView8"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"
            android:layout_marginLeft="17dp"
            android:layout_marginTop="16dp"

            android:tag="7" />

        <ImageView
            android:id="@+id/imageView9"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_margin="10dp"
            android:layout_marginLeft="12dp"
            android:layout_marginTop="16dp"

            android:tag="8" />


    </GridLayout>

NO Images are seen This Problem is not going off please help BUt this thing is working on Andriod Emulator The same Thing is working in EMultaor

I have also re-installed the android studio but in vain no effect is seen I also have tried by creating a new project and by restarting the application

You need to specify android:src="@..." in your ImageViews if you want to display them in the design preview.
If you only set the Image in your Activity class, like

((ImageView)findViewById(R.id.imageView1)).setImageDrawable(...);

they will not be displayed until the program is executed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM