1

Warum schneidet mein TextView ScrollView auf der rechten Seite der Aktivität und wie es zu beheben?Warum TextView schneidet mit ScrollView?

Dies ist ein Screenshot meiner Aktivität.

Example

Dieser Code XML meiner Aktivität.

<?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:layout_marginBottom="16dp" 
    android:layout_marginLeft="16dp" 
    android:layout_marginRight="16dp" 
    android:layout_marginTop="16dp" 
    android:orientation="vertical"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

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

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="@string/rules" 
       android:textSize="@dimen/text_font_tall" 
       android:textStyle="bold|italic" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="start" 
       android:text="@string/rules_text" 
       android:textSize="@dimen/text_font_medium" /> 

     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 
+1

überprüfen Sie die Eigenschaft scrollbarStyle Ihrer ScrollView. https://developer.android.com/reference/android/view/View.html#attr_android:scrollbarStyle mit outsideInset oder outsideOverlay – njzk2

Antwort

2

Verwenden Sie den Rand für das zweite LinearLayout auf die gleiche Weise wie für das erste LinearLayout.

android:layout_margin="16dp" 

BTW: solange die Parameter gleich sind für alle die Margen (layout_marginTop, layout_marginBottom, layout_marginLeft und layout_marginRight) Sie einfach nur ein Attribut verwenden: layout_margin

BTW2: Haben Sie wirklich brauchen das übergeordnete LinearLayout? Sie können es so versuchen:

<ScrollView> 
    <LinearLayout> 
     <TextView/> 
     <TextView/> 
    </LinearLayout> 
</ScrollView> 
+0

Vielen Dank! Es klappt. – Kostya

Verwandte Themen