简体   繁体   English

如何在 Android Studio 2.2 上刷新预览?

[英]How to refresh preview on Android Studio 2.2?

Now on Android Studio 2.2 on new Preview mode, there are no more refresh button :现在在新预览模式下的Android Studio 2.2上,不再有刷新按钮

在此处输入图片说明

  • Image 1: Preview on Android Studio 2.2 (without refresh button)图 1:在 Android Studio 2.2 上预览(无刷新按钮)
  • Image 2: Preview on Android Studio 2.1 (with refresh button)图 2:在 Android Studio 2.1 上预览(带刷新按钮)

Does anyone know how to display it again?有谁知道如何再次显示它? Or with shortcut maybe?或者可能有捷径?

Edit: If I change a drawable by example and that the change does not appear in the layout, the only method that works for me is closed and restart the project.编辑:如果我通过示例更改可绘制对象并且更改未出现在布局中,则唯一对我有用的方法是关闭并重新启动项目。 If I close the layout and as I re-opens nothing happens.如果我关闭布局并在重新打开时没有任何反应。 Same result using the "Synchronized" button.使用“同步”按钮的结果相同。

Refresh feature is not removed, it is there;刷新功能没有被移除,它就在那里; It's pretty simple to refresh:刷新非常简单:

Click on the preview screen to make sure preview window has the focus and press R .单击预览屏幕以确保预览窗口具有焦点并按R It should display the progress in the right-top corner while refreshing.它应该在刷新时在右上角显示进度。

If it doesn't work for any reason, switch to design tab and press R , it refreshes the layout instantly.如果由于任何原因它不起作用,请切换到设计选项卡并按R ,它会立即刷新布局。

I think it is a small bug.我认为这是一个小错误。 But I find a hack solution to resolve the problem, you can modify the a resource id to a wrong name, for example, you have a resource named 'ic_launcher', when you input 'ic_launcher1', you can find the interface like that:但是我找到了一个解决问题的hack解决方案,您可以将a资源ID修改为错误的名称,例如,您有一个名为'ic_launcher'的资源,当您输入'ic_launcher1'时,您可以找到这样的界面:

在此处输入图片说明

next step, click refresh icon(sometimes it is 'clear cache' label).下一步,单击刷新图标(有时是“清除缓存”标签)。 it is works for me.它对我有用。

I have try to change the orientation, but it not works when I replace a exist image file.我尝试更改方向,但是当我替换现有图像文件时它不起作用。

May your problem is same as : http://stackoverflow.com/questions/39646639/android-studio-2-2-layout-editor-refresh-button可能你的问题是一样的: http : //stackoverflow.com/questions/39646639/android-studio-2-2-layout-editor-refresh-button

Display again?再显示?

I guess you cant.我猜你不能。 Apparently the refresh functionality has been removed because they think the processing will happen much faster and will auto-refresh the previews real time.显然,刷新功能已被删除,因为他们认为处理会更快,并且会实时自动刷新预览。 The Layout Editor's document has no mention of refresh functionality.布局编辑器的文档没有提到刷新功能。

Shortcut?捷径?

If you are faster in making changes to your layout than Android-studio refreshes, you could try toggling between the design and blueprint views using the shortcut B如果您更改布局的速度比 Android-studio 刷新的速度快,您可以尝试使用快捷键Bdesign视图和blueprint视图之间切换

Refer the Layout Editor Official Documentation for other shortcuts you might feel comfortable with or works for you.请参阅 布局编辑器官方文档以了解其他您可能觉得合适或适合您的快捷方式。

There is no refresh button in stable version of android studio 2.2 for preview. android studio 2.2 稳定版中没有用于预览的刷新按钮。 But there is a work around to do so.但是有一种解决方法可以做到这一点。 By toggling the orientation button in an editor will refreshes the changes!通过切换编辑器中的方向按钮将刷新更改!

So do the Simple Step.简单的步骤也是如此。 When you change your layout then save it and clean your project.当您更改布局时,请保存并清理您的项目。 go to menu Build -> Clean Project.

I Hope this will help you.我希望这会帮助你。

我也有同样的问题,有时更改 Android 版本会起作用,如果您清理/重建项目,它肯定会起作用

Find the double diagonal lines below your preview layout and click them.找到预览布局下方的双对角线并单击它们。 It will refresh your layout.它将刷新您的布局。

双对角线

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

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