Java 如何在android中的元素上显示
我正在按照一个教程制作tic-tac-toe游戏,我希望当用户赢得游戏时,我的图像弹出并显示在所有其他背景图像上。图像弹出并显示游戏获胜,图像覆盖所有其他元素。相反,元素显示在图像上Java 如何在android中的元素上显示,java,android,android-studio,mobile,Java,Android,Android Studio,Mobile,我正在按照一个教程制作tic-tac-toe游戏,我希望当用户赢得游戏时,我的图像弹出并显示在所有其他背景图像上。图像弹出并显示游戏获胜,图像覆盖所有其他元素。相反,元素显示在图像上 //用于显示图像的弹出窗口 //弹出窗口的结尾 有两种方法可以做到这一点 1)将您的奖杯布局作为ConstraintLayout <?xml version="1.0" encoding="utf-8"?> <androidx.constr
//用于显示图像的弹出窗口
//弹出窗口的结尾
有两种方法可以做到这一点
1)将您的奖杯布局作为ConstraintLayout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".MainActivity">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a00">
<!--Your Views-->
</GridLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF018786"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="80dp"
app:srcCompat="@drawable/trophy_istock" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
由于某种原因,我们无法看到该图像,您能再次尝试上载它吗?
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".MainActivity">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a00">
<!--Your Views-->
</GridLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF018786"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="80dp"
app:srcCompat="@drawable/trophy_istock" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF018786"
android:gravity="center"
android:elevation="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="80dp"
app:srcCompat="@drawable/trophy_istock" />
</RelativeLayout>
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a00">
<!--Your Views-->
</GridLayout>
</androidx.constraintlayout.widget.ConstraintLayout>