EditText 未显示在预览屏幕中
EditText is not showing in the preview screen
我的 android 工作室 IDE 有一个奇怪的问题。每当我使用 EditText 时,它的预览都不会显示在 android studio 的预览屏幕中。我尝试了不同的布局,但它不起作用。问题仅出在我的笔记本电脑上 运行 在我朋友的笔记本电脑上完全没问题。我几乎尝试了一切,例如更改颜色、卸载整个 android 工作室,但没有任何效果。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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">
<EditText
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter name"
android:textColor="@color/black"
android:textColorHint="@color/black"
android:textSize="30dp" />
</LinearLayout>
您的 IDE 似乎处于深色模式
检查正确的主题也更高
(通过切换到深色模式从 EditText
中删除 android:textColor="@color/black"
)
在 tools:context=".MainActivity"
行中,您在 Android Studio
中的预览会采用您在 MainActivity
的 onCreate
中进行的所有设置。你在运行时改变 EditText
的颜色吗?
不过,如果您使用 LinearLayout
,请将 android:orientation="vertical"
或 horizontal
设置为 LinearLayout
禁用布局渲染引擎
我曾经遇到过这样的问题,即某些组件可以正常显示或根本不显示任何内容。禁用此实验性功能后,就没有问题了。尝试一次..
我已经尝试了收到的所有答案,但没有任何效果,最后我现在使用 EditText
的替代方案,即 TextInputEditText
,对我来说效果很好。
我的 android 工作室 IDE 有一个奇怪的问题。每当我使用 EditText 时,它的预览都不会显示在 android studio 的预览屏幕中。我尝试了不同的布局,但它不起作用。问题仅出在我的笔记本电脑上 运行 在我朋友的笔记本电脑上完全没问题。我几乎尝试了一切,例如更改颜色、卸载整个 android 工作室,但没有任何效果。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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">
<EditText
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter name"
android:textColor="@color/black"
android:textColorHint="@color/black"
android:textSize="30dp" />
</LinearLayout>
您的 IDE 似乎处于深色模式
检查正确的主题也更高
(通过切换到深色模式从 EditText
中删除 android:textColor="@color/black"
)
在 tools:context=".MainActivity"
行中,您在 Android Studio
中的预览会采用您在 MainActivity
的 onCreate
中进行的所有设置。你在运行时改变 EditText
的颜色吗?
不过,如果您使用 LinearLayout
,请将 android:orientation="vertical"
或 horizontal
设置为 LinearLayout
禁用布局渲染引擎
我曾经遇到过这样的问题,即某些组件可以正常显示或根本不显示任何内容。禁用此实验性功能后,就没有问题了。尝试一次..
我已经尝试了收到的所有答案,但没有任何效果,最后我现在使用 EditText
的替代方案,即 TextInputEditText
,对我来说效果很好。