首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何使我的布局能够向下滚动?

如何使我的布局能够向下滚动?
EN

Stack Overflow用户
提问于 2010-09-29 14:17:08
回答 5查看 219.8K关注 0票数 98

我无法向下滚动屏幕来查看"Replied By:“部分中的数据。如何使我的布局可滚动?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2010-09-29 14:19:54

只需将所有这些都封装在一个ScrollView

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <!-- Here you put the rest of your current view-->
</ScrollView>

正如David Hedlund所说,ScrollView只能包含一项...所以如果你有这样的东西:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <!-- bla bla bla-->
</LinearLayout>

您必须将其更改为:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
        <!-- bla bla bla-->
    </LinearLayout>
</ScrollView>
票数 214
EN

Stack Overflow用户

发布于 2013-06-11 12:20:02

对于使用滚动视图和相对布局:

代码语言:javascript
复制
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:background="@drawable/background_image"
    >

    <!-- Bla Bla Bla i.e. Your Textviews/Buttons etc. -->
    </RelativeLayout>
</ScrollView>
票数 44
EN

Stack Overflow用户

发布于 2018-03-03 02:48:47

只需将所有这些都封装在一个ScrollView中

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>

<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="com.ruatech.sanikamal.justjava.MainActivity">
<!-- Here you put the rest of your current view-->
</ScrollView>
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3819189

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档