1

Почему мой TextView пересекается с ScrollView в правой части Activity и как его исправить?Почему TextView пересекается с ScrollView?

Это снимок экрана моей деятельности.

Example

Это код XML моей деятельности.

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

проверить свойства прокруткиbarStyle вашего ScrollView. https://developer.android.com/reference/android/view/View.html#attr_android:scrollbarStyle using outsideInset или outsideOverlay – njzk2

ответ

2

Использовать маржу для второго LinearLayout так же, как и для первого LinearLayout.

android:layout_margin="16dp" 

КСТАТИ: пока параметры одинаковы для всех полей (layout_marginTop, layout_marginBottom, layout_marginLeft и layout_marginRight) вы можете просто использовать только один атрибут: layout_margin

BTW2: Вам действительно нужно родительский LinearLayout? вы можете попробовать:

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

Спасибо! Оно работает. – Kostya