安卓系统:滚动时顶部屏幕消失



我正在尝试创建一个android应用程序。此应用程序只有一个屏幕。在这个屏幕中,需要能够向下滚动。

现在我有了这个代码:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >
    <EditText
        android:id="@+id/name1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <ImageButton
        android:id="@+id/calculate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/button" />
    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical" >
        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/image" />
        <CheckedTextView
            android:id="@+id/score"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </FrameLayout>
    <CheckedTextView
        android:id="@+id/quote"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>

但是,当CheckedTextField包含大量文本并且我需要滚动时,滚动会出现,但我的窗口顶部不见了。所以我再也看不到第一个EditText"name1"了。我也无法通过滚动来取回它。。。

有谁能给我一个解决方案吗?

提前Tnx!

我使用以下内容,无论ScrollView中有多少文本/数据,它都会给我一个永久的标题区域。您可以用EditText替换外部LinearLayout的内容吗?希望这能有所帮助。不管怎样对我有用!

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:background="@color/bto_light_green">
 <LinearLayout android:orientation="horizontal" android:id="@+id/linear1"
    android:background="@color/bto_dark_green" android:layout_width="fill_parent"
    android:gravity="center_vertical" android:layout_height="wrap_content"
    android:paddingTop="4dip">
    <Button android:id="@+id/helpBackButton" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Back" />
    <TextView android:id="@+id/Info1" android:textSize="14dip"
        android:paddingLeft="3dip" android:textColor="@color/white"
        android:textStyle="bold" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_weight="1.0"
        android:text="Help" />
 </LinearLayout>
 <ScrollView android:id="@+id/ScrollView01"
    android:layout_width="wrap_content" android:layout_below="@+id/linear1"
    android:fillViewport="true" android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
        android:background="@color/bto_light_green"   android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView android:id="@+id/helptTitle1" android:textSize="16dip"
            android:paddingLeft="3dip" android:textColor="@color/bto_dark_green"
            android:textStyle="bold" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1.0"
            android:text="First things first..." />
        <TextView android:id="@+id/Help1" android:textSize="14dip"
            android:paddingLeft="3dip" android:textColor="@color/black"
            android:textStyle="bold" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1.0"
            android:text="Help coming soon, be patient..." />
        <TextView android:id="@+id/helptTitle2" android:textSize="16dip"
            android:paddingLeft="3dip" android:textColor="@color/bto_dark_green"
            android:textStyle="bold" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1.0"
            android:text="Other settings..." />
        <TextView android:id="@+id/Help2" android:textSize="14dip"
            android:paddingLeft="3dip" android:textColor="@color/black"
            android:textStyle="bold" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1.0"
            android:text="Help coming soon, be patient..." />
    </LinearLayout>
  </ScrollView>
</LinearLayout>

尝试

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >
    <EditText
       android:id="@+id/name1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" />
    <ImageButton
       android:id="@+id/calculate"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:src="@drawable/button" />
    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical" >
       <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/image" />
       <CheckedTextView
           android:id="@+id/score"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:scrollbars = "vertical"
           android:maxLines = "5"
       />
     </FrameLayout>
    <CheckedTextView
        android:id="@+id/quote"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:scrollbars = "vertical"
        android:maxLines = "5"
    />

活动中文本字段的setMovementMethod:

.....
 ((CheckedTextView)findViewById(R.id.ID)).setMovementMethod(new ScrollingMovementMethod());

最新更新