简体   繁体   English

Android Studio - TextView 未显示在设计视图布局中

[英]Android Studio - TextView not showing in design view layout

I am brand new to trying out an android app.我是尝试 android 应用程序的新手。 I started to follow the online tutorial ( https://developer.android.com/training/basics/firstapp/building-ui ), but getting a bit frustrated at adding a new TextView, as according to the tutorial, it should show in design view, and let me move it around.我开始遵循在线教程( https://developer.android.com/training/basics/firstapp/building-ui ),但是在添加新的 TextView 时有点沮丧,根据教程,它应该显示在设计视图,让我移动它。 It is invisible to me in design view though, and I can only see it by running an emulation.但是在设计视图中它对我来说是不可见的,我只能通过运行仿真才能看到它。 Please can someone let me know if I am doing something wrong?如果我做错了什么,请有人告诉我吗? or something the tutorial does not tell you?或者教程没有告诉你的东西? or is this just a bug?或者这只是一个错误?

Android Studio 截图

Thank you in advance for any advice you can offer.预先感谢您提供的任何建议。

There is a bug in latest sdk 28 ,最新的 sdk 28 中有一个错误,

Change the compileSdkVersion 27更改compileSdkVersion 27

targetSdkVersion 27

and

implementation 'com.android.support:appcompat-v7:27.1.1'

Update:更新:

This is said to fix problem but I did not test it yet据说这可以解决问题,但我还没有测试

In styles.xml change the parent theme for your app to Base.Theme.AppCompat instead of Theme.AppCompat在styles.xml 中将您的应用程序的父主题更改为Base.Theme.AppCompat而不是Theme.AppCompat

I faced this issue too, this is a issue from the latest support.appCompact .我也遇到了这个问题,这是来自最新的support.appCompact的问题。

Inside gradle dependencies if your using,如果您使用,在gradle依赖项中,

implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'

change to改成

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

This will fix the issue这将解决问题

您可以在组件树中看到它,因此,如果您想修改或删除它,可以从那里进行。

First and foremost, check to see if your dependencies match your SDK level .首先,检查您的依赖项是否与您的 SDK 级别匹配 To check this, go to your app.gradle file and check every highlighted statement for version conflicts.要检查这一点,请转到您的 app.gradle 文件并检查每个突出显示的语句是否存在版本冲突。

If this doesn't work, your next debugging step should be to restart your Android studio .如果这不起作用,您的下一个调试步骤应该是重新启动您的 Android studio Since the view shows in your component tree (and in your emulator), it ought to show in your preview.由于视图显示在您的组件树(以及您的模拟器)中,因此它应该显示在您的预览中。 Previews in android studio lag sometimes due to various reasons (mostly machine related).由于各种原因(主要是机器相关),android studio 中的预览有时会滞后。

If it still doesn't show up after restarting, the problem might be a larger scale IDE issue and you should consider updating your question accordingly.如果重新启动后仍然没有出现,则问题可能是更大的 IDE 问题,您应该考虑相应地更新您的问题。

I hope this helps.. Merry coding!!我希望这会有所帮助.. 编码快乐!!

Found an easier way than adding code or changing SDK.找到了比添加代码或更改 SDK 更简单的方法。 It is just hidden and you have to show it by checking the "Show layout Decorations"它只是隐藏的,您必须通过选中“显示布局装饰”来显示它

Hope it helps.希望能帮助到你。

PS it also solves the hidden toolbar problem Picture of where to find it PS它也解决了隐藏的工具栏问题图片在哪里可以找到它

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

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