简体   繁体   English

Android Studio EditText 未出现在预览 API 29 中

[英]Android Studio EditText not Appearing in preview API 29

Hello this is my android studio project.您好,这是我的 android studio 项目。 I have created a EditText which actually works normally on my virtual machine, but it doesn't appear properly in the preview.我创建了一个 EditText,它实际上在我的虚拟机上正常工作,但它在预览中没有正确显示。 I had sdk level 29 and tried downgrading to 28 however that did not fix anything.我的 sdk 级别为 29 并尝试降级到 28,但这并没有解决任何问题。 I am unsure of the reason the preview is not appearing.我不确定预览没有出现的原因。

我的 xml 文件和预览。

I don't know why you want do that (setting a text in an EditText)我不知道你为什么要这样做(在 EditText 中设置文本)

btw you can use this way to set the text in it https://stackoverflow.com/a/4594761/13295974顺便说一句,您可以使用这种方式来设置其中的文本https://stackoverflow.com/a/4594761/13295974

if you want to set a hint in your EditText(it is better than setting a text in it) you can use this in xml如果你想在你的 EditText 中设置一个提示(它比在其中设置一个文本更好)你可以在 xml 中使用它

android:hint="your hint"

I suggest you to use hint in the place of text我建议您在文本位置使用提示

Good Luck祝你好运

Refresh the layout to reload all the elements.刷新布局以重新加载所有元素。 Also, it is better to show the name as {android:hint="name"} instead of the default {android:text="Name"}.此外,最好将名称显示为 {android:hint="name"} 而不是默认的 {android:text="Name"}。

I had the same issue on Android studio 4.2.1, where only EditTexts were not visible on the preview.我在 Android studio 4.2.1 上遇到了同样的问题,其中只有 EditTexts 在预览中不可见。

I fixed it like so:我是这样修复的:

File->Settings->Experimental-> (Enable Live Layout Inspector)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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