-1

Ich habe 4 TextView s in meinem Activity und ich verwende LinearLayout mit vertikaler Ausrichtung. Top 1 TextView ist eine Art Header (keine Notwendigkeit zu scrollen) als nächstes ist eine Art von Beschreibung, die ich scrollbar machen möchte. Das dritte ist wieder eine Überschrift (kein Scroll benötigt) und 4. ist die Beschreibung (muss scrollen). Ich versuchte, aber nur top TextView (Header) und 2. TextView (Beschreibung) wird auf dem Bildschirm angezeigt. Beschreibung ist scrollbar, aber das Problem ist, andere zwei TextView sind versteckt. Seine Art von dummer Frage zu fragen, aber ich bin irgendwie hier fest, weil ich neu bei Android bin. Hier ist meine xml.Scrollview in zwei Linearlayouts?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/list_view" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_marginTop="?android:attr/actionBarSize" 
android:orientation="vertical" 
android:padding="15dp" 

> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="#d0f7c9" 
    android:orientation="vertical" 
    android:padding="10dp" 

    > 

    <TextView 
     android:id="@+id/tvTitle" 
     style="?android:attr/listSeparatorTextViewStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:textColor="#ffffff" 
     android:textSize="20dp" /> 

</LinearLayout> 


<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true"> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#b3cff4" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/tvShow" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="@color/black" 
      android:textSize="20dp" /> 
    </LinearLayout> 
</ScrollView> 


<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Program Output" 
    android:textColor="@color/black" 
    android:textSize="25dp" /> 


<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="#d2b3f4"> 

     <TextView 
      android:id="@+id/tvOutput" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="#ffffff" 
      android:textSize="20dp" /> 

    </LinearLayout> 

</ScrollView> 

Antwort

0

Sie können wie diese versuchen,

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       android:weightSum="2"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:background="#d0f7c9" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/tvTitle" 
      style="?android:attr/listSeparatorTextViewStyle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:text="Top Title" 
      android:textColor="#ffffff" 
      android:textSize="20dp"/> 

     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#b3cff4"> 

      <TextView 
       android:id="@+id/tvShow" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:textSize="20dp"/> 
     </ScrollView> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/tvTitle1" 
      style="?android:attr/listSeparatorTextViewStyle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:text="Seconf Title" 
      android:textColor="#ffffff" 
      android:textSize="20dp"/> 

     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#b3cff4"> 

      <TextView 
       android:id="@+id/tvShow1" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:textSize="20dp"/> 
     </ScrollView> 
    </LinearLayout> 

</LinearLayout> 
+0

Sie meinen Tag. Vielen Dank –

0

So wie ich dies wahrscheinlich tun würde, ist zwei Layouts erstellen. Eines davon ist die Textansicht Nummer 1 und 2. Das andere Layout ist 3 und 4. Und dann im ersten Layout das zweite.

<include layout="@layout/layout2"/> 

So etwas wie das. LAYOUT ONE

<linearlayout> 
<text view> 
<linearlayout> 
<scrollview> 
<textview> 
</scrollview> 
</linearlayout> 

<include layout="@layout/layout2"/> 

</linearlayout> 

LAYOUT ZWEI

<linearlayout> 
    <text view> 
    <linearlayout> 
    <scrollview> 
    <textview> 
    </scrollview> 
    </linearlayout> 
    </linear layout> 
Verwandte Themen