使用白色图像隐藏 Android Studio 中的所有 textView
Hiding all textViews in Android Studio with a white image
我试图用白色图像隐藏屏幕上的所有内容 10 秒,但无论如何文本似乎都显示在白色图像之上。有没有办法使用白色图像隐藏 textView(或将来的任何其他 imageView)?谢谢!
这是我的主要内容 activity class:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ImageView splash = findViewById(R.id.imageView);
splash.setScaleType(ImageView.ScaleType.FIT_XY);
splash.postDelayed(new Runnable() {
@Override
public void run() {
splash.setVisibility(View.GONE);
}
}, 10000);
}}
这是我的 XML 文件:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.544"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/white" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="172dp"
android:layout_marginTop="268dp"
android:text="TextToHide"
android:textSize="36sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
如果你想让 ImageView
出现在 TextView
你必须先添加到 XML TextView
然后 ImageView
像这样:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.544"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="172dp"
android:layout_marginTop="268dp"
android:text="TextToHide"
android:textSize="36sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/white" />
现在你的TextView
将落后于ImageView
我不知道你想做什么,但我认为将 TextView
可见性设置为 GONE
或 INVISIBLE
比将 ImageView
更容易] 在您想隐藏的内容上。
我试图用白色图像隐藏屏幕上的所有内容 10 秒,但无论如何文本似乎都显示在白色图像之上。有没有办法使用白色图像隐藏 textView(或将来的任何其他 imageView)?谢谢!
这是我的主要内容 activity class:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ImageView splash = findViewById(R.id.imageView);
splash.setScaleType(ImageView.ScaleType.FIT_XY);
splash.postDelayed(new Runnable() {
@Override
public void run() {
splash.setVisibility(View.GONE);
}
}, 10000);
}}
这是我的 XML 文件:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.544"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/white" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="172dp"
android:layout_marginTop="268dp"
android:text="TextToHide"
android:textSize="36sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
如果你想让 ImageView
出现在 TextView
你必须先添加到 XML TextView
然后 ImageView
像这样:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.544"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="172dp"
android:layout_marginTop="268dp"
android:text="TextToHide"
android:textSize="36sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/white" />
现在你的TextView
将落后于ImageView
我不知道你想做什么,但我认为将 TextView
可见性设置为 GONE
或 INVISIBLE
比将 ImageView
更容易] 在您想隐藏的内容上。