ScrollView

  • 4 Antworten
  • Letztes Antwortdatum
F

Freaky256

Neues Mitglied
0
Ich hab ein RelativeLayout das verschiedene Elemente beinhaltet und inkludiert in dieses Layout auch eine Titelleiste am oberen Rand. Nun moechte ich dass alles ausser dieser Titelleiste Scrollable ist! Weis aber nicht so ganz wie ich das Anstellen soll bisher hab ich folgendes:

Code:
<?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">


<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/main"
    >

    <Button 
        android:id="@+id/title"
        android:layout_width="fill_parent"
        android:layout_height="20dp"
        />
     </RelativeLayout>
</ScrollView>
Ich hab zunaechst versucht die ScrollView einfach innerhalb des RelativeLayout zu legen und die Elemente einfach dort hinzuzufuegen aber dann habe ich keine Moeglichkeit mehr diese zu Positionieren...
Weis vielleicht jemand eine Loesung dafuer?
 
du musst zu erst das RelativLayout setzten dann die ScrollView und dann bspw ein LinearLayout dann kannst du deine ganzen geschichten rein hauen ...

Code:
<RelativeLayout 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" >

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView" />

        </LinearLayout>

    </ScrollView>

</RelativeLayout>
 
Ja aber so kann ich zwar die ScrollView relative zu anderen Objekten ausrichten aber nicht Objekte innerhalt der ScrollView oder?
Beispielsweise:

Code:
<RelativeLayout>

      <Button 
        android:id="@+id/title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />


       <ScrollView>
          
                <TextView
                      android:layout_below="title"/>
    
       </ScrollView>


</RelativeLayout>
 
du kannst in die scrollview auch ein Layout rein packen bspw. ein LinearLayout dann kannst du es positionieren.

Du musst dir halt merken das die scrollview nur ein direktes Kind managen kann.
 
Perfekt, hab einfach in die ScrollView ein neues RelativeLayout hineingesteckt und jetzt funktionierts!
Danke fuer die Hilfe
 
Zurück
Oben Unten