2012-03-26 15 views
1

Ich versuche, eine Android App zu erstellen. Diese App hat nur einen Bildschirm. Innerhalb dieses Bildschirms muss es möglich sein, nach unten zu scrollen.Android: Top-Bildschirm verschwinden beim Scrollen

Jetzt habe ich diesen Code:

<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> 

Aber wenn die CheckedTextField viel Text enthält, und ich brauche zu blättern, die Scroll erscheint aber die Spitze von meinem Fenster verschwunden ist. So sehe ich den ersten EditText 'name1' nicht mehr. Ich kann es auch nicht durch Scrollen zurückbekommen ...

Wer kann mir eine Lösung geben?

Tnx im Voraus!

Antwort

0

Ich verwende folgendes, was mir einen permanenten Kopfbereich gibt, unabhängig davon, wieviel Text/Daten in der ScrollView sind. Sie können den Inhalt des äußeren LinearLayout durch Ihren EditText ersetzen? Hoffe das hilft. Funktioniert für mich sowieso!

<?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

Es ist nicht, dass ich die EditText wollen am oberen Rand des Bildschirms befestigt werden. Es ist wirklich weg, wenn die Bildlaufleiste erscheint und das ist nicht der Punkt. Ich will nur durch meinen ganzen Bildschirm scrollen, wenn du verstehst was ich meine ... – user1293065

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" 
    /> 

Und setMovementMethod für Textfeldern in Aktivität Versuchen:

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