如何在android中滚动屏幕

时间:2011-05-07 04:57:58

标签: android scroll

我正在学习android。我创建了一个简单的xml屏幕,但数据已经离开屏幕而屏幕没有滚动。任何人都可以告诉我如何制作可滚动的手机屏幕吗?

5 个答案:

答案 0 :(得分:5)

答案 1 :(得分:2)

以下是一些固定页眉和固定页脚以及滚动正文的代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_height="fill_parent"
  android:id="@+id/relativeLayout1"
  android:layout_width="wrap_content">
<TextView
  android:text="Header"
  android:id="@+id/textViewHeader"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
</TextView>
<TextView
  android:layout_alignParentBottom="true"
  android:text="Footer"
  android:id="@+id/textViewFooter"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
</TextView>
<ScrollView
  android:layout_above="@id/textViewFooter"
  android:layout_below="@id/textViewHeader"
  android:layout_height="fill_parent"
  android:layout_width="fill_parent"
  >
<LinearLayout
  android:layout_below="@id/textViewHeader"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
<TextView android:text="@string/about_tlh_body"
  android:id="@+id/textViewBody"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</ScrollView>
</RelativeLayout>

玩得开心。

答案 2 :(得分:0)

将您的活动设为ListActivity

这是一个实现listView / ListActivity

的示例

http://p-xr.com/android-tutorial-how-to-parseread-xml-data-into-android-listview/

滚动到帖子的底部,找到Eclipse项目以查看完整的实现。

您还可以使用http://developer.android.com/reference/android/widget/ScrollView.html

答案 3 :(得分:0)

puth整个布局在scrollView.i.e中,最顶层/父布局是scrollview

答案 4 :(得分:0)

只需将这段代码放入您的AndroidManifest.xml活动中

android:windowSoftInputMode="stateVisible|adjustResize"