2012-03-26 76 views
1

我正試圖創建一個android應用程序。這個應用程序只有一個屏幕。在此屏幕中,需要向下滾動。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提前!

回答

0

我使用以下內容,它給了我一個永久的標題區域,而不管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> 
+0

這不是我想要的EditText上被固定在屏幕的頂部。當滾動條出現時,它確實消失了,這不是重點。我只是想滾動整個屏幕,如果你明白我的意思...... – user1293065 2012-03-26 14:56:18

0

嘗試

<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爲的TextField的活動:

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