添加ScrollView时的Android Studio呈现 [英] Android Studio rendering when ScrollView is added

查看:78
本文介绍了添加ScrollView时的Android Studio呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio 1.3.2.因此,我正在做一个测试应用程序,并且我有一个LinearLayout组.布局的预览是这样的: http://imgur.com/EkPv1v2

I am using Android Studio 1.3.2. So, I was doing a test app and I have a LinearLayout group. The preview of the layout is this : http://imgur.com/EkPv1v2

接下来,我在LinearLayout组上方添加了一个ScrollView组.然后预览仅显示以下内容: http://imgur.com/ccb2IFu

Next, I added a ScrollView group above the LinearLayout group. Then the preview only shows this : http://imgur.com/ccb2IFu

操作栏不见了.手机的框架不见了.

The action bar is gone. The frame of the phone is gone.

但是,如果将ScrollView组放在主要LinearLayour组之后,则可以正常渲染.

However, if I put the ScrollView group after the main LinearLayour group, then rendering is a-ok.

发生了什么事?我想念什么吗?

What's happening? Am I missing something?

下面是带有ScrollView的XML布局:

Below is the XML layout with the ScrollView :

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:text="Toppijjngs"
        android:textAllCaps="true" />

    <CheckBox
        android:id="@+id/notify_me_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:onClick="hasTopping"
        android:paddingLeft="24dp"
        android:text="Whipped Cream"
        android:textSize="16sp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:text="quantity"
        android:textAllCaps="true" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:onClick="decrement"
            android:text="-" />

        <TextView
            android:id="@+id/quantity_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:text="0"
            android:textColor="#000000" />

        <Button
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:onClick="increment"
            android:text="+" />

    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:text="order summary"
        android:textAllCaps="true" />

    <TextView
        android:id="@+id/order_summary_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:text="$0.00"
        android:textColor="#000000" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:onClick="submitOrder"
        android:text="order" />

</LinearLayout>

推荐答案

由于ScrollView的本质,Android Studio隐藏了电话框和操作栏,因此您可以看到完整的视图,因此,如果ScrollView大于在手机屏幕上,预览显示了整个ScrollView.

Due to the nature of the ScrollView, Android Studio hides the phone frame and action bar so you can see the complete view, so if your ScrollView is larger than the screen of a phone, the preview shows the whole ScrollView.

如果要在预览窗口中临时查看电话框,可以执行以下操作:

If you want to see temporarily the phone frame in the preview window, you can do this:

  1. 在渲染配置"按钮中,选择预览代表样本"选项.

  1. 在同一按钮中,现在选择无"选项.

  1. 电话框将会出现(没有操作栏)

但是,一旦您切换到另一个文件,或者切换到设计"模式,再回到文字"模式,电话框就会消失.

However, the phone frame will dissapear once you switch to another file, or switch to Design mode, and back to Text mode.

在设计"模式下,按下切换视口渲染模式"按钮,您可以在电话框和操作栏中看到ScrollView:

You can see your ScrollView inside the phone frame and action bar in the Design mode pressing the "Toggle Viewport Render Mode" button:

但是,如果ScrollView大于电话屏幕,您将看不到所有内容.

But you will not see all the content if the ScrollView is larger than phone screen.

仅此而已!

这篇关于添加ScrollView时的Android Studio呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆