2017-02-20 49 views
0

В моем коде scrollview не работает. Когда я напрямую вызываю этот макет, scrollview работает отлично. Но когда я вызываю этот макет из другого представления, этот макет не прокручивается.Scrollview не работает?

  <ScrollView     
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/scrollData" 
      android:layout_width="fill_parent" 
      android:layout_height="match_parent" 
      android:fillViewport="true" 
      android:background="#000"> 
      <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      android:background="@color/setting_back">   
      <LinearLayout 
      android:id="@+id/about" 
      android:layout_width="match_parent" 
      android:layout_height="70dip" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/background_with_shadow"> 
     <TextView 
        android:id="@+id/star" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:layout_marginLeft="10dip" 
        android:text="@string/fa_star" 
        android:textColor="#3a3a3a" 
        android:textSize="30sp"/> 
      <TextView 
        android:id="@+id/about_id" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="#000000" 
        android:layout_gravity="center_vertical" 
        android:layout_marginLeft="10dip" 
        android:textSize="20sp" 
        android:text="About"/> 
      <LinearLayout 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:gravity="right" 
       android:layout_marginRight="10dp" 
       android:orientation="horizontal" > 
        <TextView 
          android:id="@+id/fa_angle_down_about" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="right" 
          android:text="@string/fa_angle_down" 
          android:textColor="#3a3a3a" 
          android:textSize="30sp"/> 
      </LinearLayout>   
     </LinearLayout> 
     <LinearLayout 
     android:id="@+id/slide_down_about" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="12dp" 
     android:layout_marginRight="12dp" 
     android:padding="10dp" 
     android:layout_gravity="center_horizontal" 
     android:background="#fff"> 
      <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="#000000" 
        android:text="@string/about_content"/> 
      </LinearLayout> 
     <LinearLayout 
     android:id="@+id/feedback" 
     android:layout_width="match_parent" 
     android:layout_height="70dip" 
     android:background="@drawable/background_with_shadow"> 
      <TextView 
        android:id="@+id/bell" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:layout_marginLeft="10dip" 
        android:text="@string/fa_feedback" 
        android:textColor="#3a3a3a" 
        android:textSize="30sp"/> 
      <TextView 
        android:id="@+id/feedback_id" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="#000000" 
        android:layout_gravity="center_vertical" 
        android:layout_marginLeft="10dip" 
        android:textSize="20sp" 
        android:text="Feedback"/> 
      <LinearLayout 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:gravity="right" 
       android:layout_marginRight="10dp" 
       android:orientation="horizontal" > 
        <TextView 
          android:id="@+id/fa_angle_down_feedback" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="right" 
          android:text="@string/fa_angle_down" 
          android:textColor="#3a3a3a" 
          android:textSize="30sp"/> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
     android:id="@+id/slide_down_feedback" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="12dp" 
     android:layout_marginRight="12dp" 
     android:padding="10dp" 
     android:background="#fff"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:background="#DBDFE2" 
       android:orientation="vertical"> 
      <EditText 
        android:id="@+id/submitfeedback" 
        android:layout_width="match_parent" 
        android:layout_height="100dp" 
        android:layout_marginBottom="20dp" 
        android:layout_marginLeft="2dp" 
        android:layout_marginRight="20dp" 
        android:background="#fff" 
        android:gravity="top" 
        android:hint="Your feedback here..." 
        android:textColor="#000000" 
        android:textColorHint="#ccc" 
        /> 
      <Button 
        android:id="@+id/submit" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:textColor="#fff" 
        android:background="#de682c" 
        android:text="submit"/> 
      </LinearLayout> 
     </LinearLayout>   
     <LinearLayout 
     android:id="@+id/terms" 
     android:layout_width="match_parent" 
     android:layout_height="70dip" 
     android:background="@drawable/background_with_shadow"> 
      <TextView 
        android:id="@+id/comment" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:layout_marginLeft="10dip" 
        android:text="@string/fa_terms" 
        android:textColor="#3a3a3a" 
        android:textSize="30sp"/> 
      <TextView 
        android:id="@+id/terms_id" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="#000000" 
        android:layout_gravity="center_vertical" 
        android:layout_marginLeft="10dip" 
        android:textSize="20sp" 
        android:text="Terms of use"/> 
      <LinearLayout 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:gravity="right" 
       android:layout_marginRight="10dp" 
       android:orientation="horizontal" > 
        <TextView 
          android:id="@+id/fa_angle_down_terms" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="right" 
          android:text="@string/fa_angle_down" 
          android:textColor="#3a3a3a" 
          android:textSize="30sp"/> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
     android:id="@+id/slide_down_terms" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="12dp" 
     android:layout_marginRight="12dp" 
     android:padding="10dp" 
     android:layout_gravity="center_horizontal" 

        android:background="#fff"> 

        <TextView  
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="#000000" 
        android:text="@string/about_content"/> 
     </LinearLayout>  
     <LinearLayout 
     android:id="@+id/privacy_policy" 
     android:layout_width="match_parent" 
     android:layout_height="70dip" 
     android:background="@drawable/background_with_shadow"> 
      <TextView 
        android:id="@+id/license" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:layout_marginLeft="10dip" 
        android:text="@string/fa_policy" 
        android:textColor="#3a3a3a" 
        android:textSize="30sp"/> 
      <TextView 
        android:id="@+id/policy_id" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="#000000" 
        android:layout_gravity="center_vertical" 
        android:layout_marginLeft="10dip" 
        android:textSize="20sp" 
        android:text="Privacy Policy"/> 
      <LinearLayout 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:gravity="right" 
       android:layout_marginRight="10dp" 
       android:orientation="horizontal" > 
        <TextView 
          android:id="@+id/fa_angle_right_down_policy" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="right" 
          android:text="@string/fa_angle_down" 
          android:textColor="#3a3a3a" 
          android:textSize="30sp"/> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
     android:id="@+id/slide_down_policy" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="12dp" 
     android:layout_marginRight="12dp" 
     android:padding="10dp" 
     android:layout_gravity="center_horizontal" 
     android:background="#fff"> 
      <TextView   
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="#000000" 
        android:text="@string/about_content"/> 
     </LinearLayout>  
</LinearLayout> 
</ScrollView> 

Я пробовал все решения от Stackoverflow.

+0

что вы имеете в виде непосредственно и с другим макетом –

+0

@ AdityaVyas-Lakhan , как вы звоните с другого взгляда? Используете ли вы '' – Tasneem

+0

@Tasneem я не звоню: D –

ответ

2

Где находится закрывающий тег scrollView? может быть, из-за этого Scrollview не работает

+0

близко бирка есть. – Mhandroid

0

Попробуйте это,

<?xml version="1.0" encoding="utf-8"?> 
    <ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/scrollData" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     android:background="#000" 
     android:focusableInTouchMode="true"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      android:background="@color/setting_back"> 
     <LinearLayout 
      android:id="@+id/about" 
      android:layout_width="match_parent" 
      android:layout_height="70dip" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/background_with_shadow"> 
      <TextView 
       android:id="@+id/star" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="10dip" 
       android:text="@string/fa_star" 
       android:textColor="#3a3a3a" 
       android:textSize="30sp"/> 
      <TextView 
       android:id="@+id/about_id" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="10dip" 
       android:textSize="20sp" 
       android:text="About"/> 
      <LinearLayout 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:gravity="right" 
       android:layout_marginRight="10dp" 
       android:orientation="horizontal" > 
       <TextView 
        android:id="@+id/fa_angle_down_about" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="right" 
        android:text="@string/fa_angle_down" 
        android:textColor="#3a3a3a" 
        android:textSize="30sp"/> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/slide_down_about" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="12dp" 
      android:layout_marginRight="12dp" 
      android:padding="10dp" 
      android:layout_gravity="center_horizontal" 
      android:background="#fff"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:text="@string/about_content"/> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/feedback" 
      android:layout_width="match_parent" 
      android:layout_height="70dip" 
      android:background="@drawable/background_with_shadow"> 
      <TextView 
       android:id="@+id/bell" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="10dip" 
       android:text="@string/fa_feedback" 
       android:textColor="#3a3a3a" 
       android:textSize="30sp"/> 
      <TextView 
       android:id="@+id/feedback_id" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="10dip" 
       android:textSize="20sp" 
       android:text="Feedback"/> 
      <LinearLayout 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:gravity="right" 
       android:layout_marginRight="10dp" 
       android:orientation="horizontal" > 
       <TextView 
        android:id="@+id/fa_angle_down_feedback" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="right" 
        android:text="@string/fa_angle_down" 
        android:textColor="#3a3a3a" 
        android:textSize="30sp"/> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/slide_down_feedback" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="12dp" 
      android:layout_marginRight="12dp" 
      android:padding="10dp" 
      android:background="#fff"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:background="#DBDFE2" 
       android:orientation="vertical"> 
       <EditText 
        android:id="@+id/submitfeedback" 
        android:layout_width="match_parent" 
        android:layout_height="100dp" 
        android:layout_marginBottom="20dp" 
        android:layout_marginLeft="2dp" 
        android:layout_marginRight="20dp" 
        android:background="#fff" 
        android:gravity="top" 
        android:hint="Your feedback here..." 
        android:textColor="#000000" 
        android:textColorHint="#ccc" 
        /> 
       <Button 
        android:id="@+id/submit" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:textColor="#fff" 
        android:background="#de682c" 
        android:text="submit"/> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/terms" 
      android:layout_width="match_parent" 
      android:layout_height="70dip" 
      android:background="@drawable/background_with_shadow"> 
      <TextView 
       android:id="@+id/comment" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="10dip" 
       android:text="@string/fa_terms" 
       android:textColor="#3a3a3a" 
       android:textSize="30sp"/> 
      <TextView 
       android:id="@+id/terms_id" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="10dip" 
       android:textSize="20sp" 
       android:text="Terms of use"/> 
      <LinearLayout 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:gravity="right" 
       android:layout_marginRight="10dp" 
       android:orientation="horizontal" > 
       <TextView 
        android:id="@+id/fa_angle_down_terms" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="right" 
        android:text="@string/fa_angle_down" 
        android:textColor="#3a3a3a" 
        android:textSize="30sp"/> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/slide_down_terms" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="12dp" 
      android:layout_marginRight="12dp" 
      android:padding="10dp" 
      android:layout_gravity="center_horizontal" 

      android:background="#fff"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:text="@string/about_content"/> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/privacy_policy" 
      android:layout_width="match_parent" 
      android:layout_height="70dip" 
      android:background="@drawable/background_with_shadow"> 
      <TextView 
       android:id="@+id/license" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="10dip" 
       android:text="@string/fa_policy" 
       android:textColor="#3a3a3a" 
       android:textSize="30sp"/> 
      <TextView 
       android:id="@+id/policy_id" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:layout_gravity="center_vertical" 
       android:layout_marginLeft="10dip" 
       android:textSize="20sp" 
       android:text="Privacy Policy"/> 
      <LinearLayout 
       android:layout_width="0dip" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:gravity="right" 
       android:layout_marginRight="10dp" 
       android:orientation="horizontal" > 
       <TextView 
        android:id="@+id/fa_angle_right_down_policy" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="right" 
        android:text="@string/fa_angle_down" 
        android:textColor="#3a3a3a" 
        android:textSize="30sp"/> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/slide_down_policy" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="12dp" 
      android:layout_marginRight="12dp" 
      android:padding="10dp" 
      android:layout_gravity="center_horizontal" 
      android:background="#fff"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:text="@string/about_content"/> 
     </LinearLayout> 
     </LinearLayout> 
    </ScrollView> 
+0

Не работает :( – Mhandroid

0

Вы должны поместить макет между ScrollView тега, когда вы включаете этот макет в другую раскладку. Это сработает.

в вашем другом макете:

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

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

</ScrollView> 
0

попробовать это, сделать пучок, как это, чтобы получить прокручивать ..

<ScrollView     
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollData" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    android:background="#000"> 

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

    <!-- PUT YOUR CONTENT/ ELEMENT IN HERE --> 

    </LinearLayout> 
</ScrollView> 
+0

'LinearLayout' внутри' ScrollView' должен иметь 'android: layout_height =" wrap_content "' вместо 'match_parent'. Он не должен соответствовать высоте ScrollView, а имеет высоту, которая представляет собой сумму высот ее дочерних элементов - и предусматривает, что высоту ScrollView, чтобы понять, как прокручивать – krossovochkin

+0

нет ее не работает для меня – Mhandroid

+0

извините - вы можете добавить это в теге ScrollView:.. андроида: layout_width = «fill_parent» андроид: layout_height = «fill_parent» андроид : fitsSystemWindows = "истина" –

 Смежные вопросы

  • Нет связанных вопросов^_^