【问题标题】:White screen error on android studio ( If anyone can please let me know)android studio上的白屏错误(如果有人可以请告诉我)
【发布时间】:2020-06-30 14:53:58
【问题描述】:

在我的手机上从 android studio 运行的应用程序显示一个空白屏幕。它只在我手机上的 android studio 中作为已安装的应用程序运行时显示白屏。什么都没有显示,但是当我在android studio上运行它时,没有错误。如果有人可以请告诉我。这是我的截图 ==>enter image description here

.....JAVA 代码....

package com.example.testvegetablewheelbarrow;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

}

....XML 代码...

<?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"
android:background="@drawable/ic_launcher_background"
tools:context=".MainActivity">

<TextView
    android:id="@+id/textView"
    android:layout_width="291dp"
    android:layout_height="110dp"
    android:textAlignment="viewStart"
    android:textColor="#E60D0D"
    android:textSize="36sp"
    android:textStyle="bold"
    android:visibility="visible"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.499"
    tools:text="Hello Wold"
    tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

【问题讨论】:

  • 添加截图让问题更相关
  • 向您发送清单代码
  • 您能向我们展示您的 Java/Kotlin 代码和布局 xml 文件吗?
  • 我上传了我的代码
  • 也许您可以尝试将android:background="@drawable/ic_launcher_background" 更改为android:background="#000000".

标签: android android-studio android-layout android-fragments android-studio-3.0


【解决方案1】:

这里的问题是由于工具:text =“Hello Wold”。它以预览模式显示。

tools:text="Hello Wold" 来自命名空间 xmlns:tools="http://schemas.android.com/tools" 因为它是为了工作室编辑器的目的而帮助编辑而不设置 android 命名空间值。当开发人员不想在布局中设置值并且可以在运行时动态设置时。

试着改成

android:text="Hello Wold"

通过此选项,如果开发人员不想设置,则可以避免显示默认值。这些工具将有助于布局设计查看和对齐。

【讨论】:

    猜你喜欢
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    相关资源
    最近更新 更多