简体   繁体   中英

How i can see long layout in preview in Android Studio

I have a long Screen, and i set ScrollView, but in Preview screen in Android Studio i do not see part of the Screen. How i can see it?在此处输入图片说明

I found another & pretty cool solution. It's not about size of the layout in preview. You can simulate scrolling instead, to see the hidden content.

Use with tools, as it has influence only in preview. Then increase/decrease value for "scroll".

<YourRootViewOfAnyType
xmlns:tools="http://schemas.android.com/tools"
...
tools:layout_marginTop="-200dp"
...
>

</YourRootViewOfAnyType>

Here's The Magic Solution :

在此处输入图片说明

Click on the highlighted button to increase the size of the preview window. Note : You can increase the size to any desired size!

在此处输入图片说明

Then use the zoom button to zoom and see the preview.

在此处输入图片说明

Here's how it will look then.

在此处输入图片说明

To get the scroll Bar in application .... 在此处输入图片说明

Use scroll view as the root view in your .xml file and then make the nesting of layouts.

If you don't want the scrolling image to fade away in app then add the code under ScrollView :

android:fadeScrollbars="false"

If you put your layouts in a ScrollView it should automatically (at least in Android Studio) show you everything.

Another workaround is to make a new AVD with a big resolution, something like 4000px height, and use that for preview, worked for me :)

Open the xml of the layout. In the preview pane press the 'Show Design + Blue print' button. This will show the design along side the blue print. Hover the mouse over the blue print, you'll then be able to scroll. The design beside it will scroll simultaneously.

在此处输入图片说明

更新您的 android studio 现在您可以在滚动时看到预览。

As Verdan answered, you should use a ScrollView.
But the trick is that the ScrollView must be your root layout (at least temporary).
So just wrap all your layout into a ScrollView (even though you have another nested one or a ListView).

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- PUT All YOUR STUFF HERE -->

</ScrollView>

Then you will see all your layout in the preview.
And when your are done you can just remove it

Open Android Studio Design View Click on the Blue Toggle Design or Blue Print Button Select Design + Blue Print

Now hover on the blueprint view and when you scroll your design layout will also scroll automatically showing you the complete view. 见示例

In Android Studio 4.1 you can easily increase height of preview by dragging the corresponding button:

展开预览尺寸按钮

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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