2017-08-02 1 views
0

Ich möchte scrollbares Layout machen, weil mein TextView langen Text hat. Ich suchte und fand eine Lösung, wie zum Beispiel eine ScrollView in meinem RelativeLayout zu erstellen und dort ein anderes RelativeLayout zu erstellen. und änderte meinen XML-Code so. aber nichts ist passiert.Wie mache ich RelativeLayout scrollbar?

das ist mein xml-Code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.arsh.fina.IntroActivity"> 

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

    <ScrollView 
     android:layout_marginTop="55dp" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="55dp"> 

     <ImageView 
      android:id="@+id/imageView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="13dp" 
      android:adjustViewBounds="true" 
      app:srcCompat="@drawable/surv1" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentStart="true" /> 


     <TextView 
      android:layout_below="@+id/imageView3" 
      android:layout_marginTop="20dp" 
      android:textColor="#FFFFFF" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="A VERY 
VERY 
VERy 
VERY TEXT"/> 


    </RelativeLayout> 

</ScrollView> 

<android.support.v4.widget.DrawerLayout 
    android:id="@+id/a1" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginTop="55dp"> 


    <android.support.design.widget.NavigationView 
     android:id="@+id/a2" 
     android:layout_gravity="right" 
     android:layout_height="match_parent" 
     android:layout_width="180dp" 
     app:headerLayout="@layout/header" 
     app:menu="@menu/drawer"/> 
</android.support.v4.widget.DrawerLayout> 

</RelativeLayout> 

Wo finde ich falsch?

Antwort

1

Damit ein vertikales Layout scrollbar ist, muss seine Layout_Höhe "wrap_content" sein. Wenn Sie es auf "match_parent" setzen, wird das Layout immer so hoch sein wie das Eltern-Element und es wird nichts zu scrollen geben, da Android so aussieht, dass es bereits vollständig sichtbar ist.

Wechsel zu

<ScrollView 
    android:layout_marginTop="55dp" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="55dp"> 

Das gleiche gilt für eine horizontale Layout natürlich, aber dann ist es layout_width die „wrap_content“ sein muss. Sie haben keine Ausrichtung in Ihrem Layout festgelegt, so dass es standardmäßig horizontal ist.

+0

danke für deine zeit. ich mache es, aber nichts ist passiert ... – Arshiiia13

Verwandte Themen