2016-06-21 91 views
0

我的ScrollView无法正常工作我无法滚动整个视图我尝试添加和删除重量但它不工作有人可以告诉我我做错了什么?以下是我的XML代码。ScrollView无法正常工作

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

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


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


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.5" 
      android:background="@android:color/darker_gray" 
      android:orientation="vertical"> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_marginTop="20dp" 
       android:src="@drawable/referfriend_screen" /> 

      <TextView 
       android:id="@+id/refersharemessage" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="20dp" 
       android:layout_marginRight="20dp" 
       android:layout_marginTop="5dp" 
       android:padding="0dp" 
       android:text="Share your referal code with a friend and earn Rs. 150/- for every share that translate to a sale" /> 


      <TextView 
       android:id="@+id/yourcode" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom|center" 
       android:layout_marginBottom="25dp" 
       android:text="Your Code" /> 


     </LinearLayout> 


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


      <LinearLayout 
       android:id="@+id/sharecodeWhatsapp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_marginTop="30dp" 
       android:background="@drawable/draw_login_edit_text" 
       android:orientation="horizontal" 
       android:padding="10dp" 
       > 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_weight="0.5" 
        android:src="@drawable/whatsapp" /> 

       <TextView 
        android:id="@+id/sharecodeWhatsapptext" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_weight="0.5" 
        android:text="Whatsapp Invite" /> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/shareCodeFacebook" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_marginTop="10dp" 
       android:background="@drawable/draw_login_edit_text" 
       android:orientation="horizontal" 
       android:padding="10dp" 
       > 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_weight="0.5" 
        android:src="@drawable/fb_icon" /> 

       <TextView 
        android:id="@+id/sharecodefacebooktext" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_weight="0.5" 
        android:text="Facebook Invite" /> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/shareCodeMore" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_marginTop="10dp" 
       android:layout_marginBottom="10dp" 
       android:background="@drawable/draw_login_edit_text" 
       android:orientation="horizontal" 
       android:padding="10dp" 
       > 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.5" 
        android:src="@drawable/more_icon" /> 

       <TextView 
        android:id="@+id/sharecodemoretext" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_weight="0.5" 
        android:text="More Apps  " /> 

      </LinearLayout> 


     </LinearLayout> 


    </LinearLayout> 

    <Button 

     android:id="@+id/referCode" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:background="@drawable/item_view_add_to_cart_click" 
     android:text="YTH45T" 
     android:textColor="@color/white_bg" /> 


</RelativeLayout> 


    </LinearLayout> 
    </ScrollView> 
+0

怎么回事? –

+0

我无法滚动我的整个视图 – stackover65

回答

0

试试这个..

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

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

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


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

       <LinearLayout 
        android:id="@+id/ll" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical" 
        android:weightSum="1"> 


        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_weight="0.5" 
         android:background="@android:color/darker_gray" 
         android:orientation="vertical"> 

         <ImageView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:layout_marginTop="20dp" 
          android:src="@drawable/referfriend_screen" /> 

         <TextView 
          android:id="@+id/refersharemessage" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_marginLeft="20dp" 
          android:layout_marginRight="20dp" 
          android:layout_marginTop="5dp" 
          android:padding="0dp" 
          android:text="Share your referal code with a friend and earn Rs. 150/- for every share that translate to a sale" /> 


         <TextView 
          android:id="@+id/yourcode" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="bottom|center" 
          android:layout_marginBottom="25dp" 
          android:text="Your Code" /> 


        </LinearLayout> 


        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:gravity="center" 

         android:orientation="vertical"> 


         <LinearLayout 
          android:id="@+id/sharecodeWhatsapp" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginLeft="10dp" 
          android:layout_marginRight="10dp" 
          android:layout_marginTop="30dp" 
          android:background="@drawable/draw_login_edit_text" 
          android:gravity="center" 
          android:orientation="horizontal" 
          android:padding="10dp"> 

          <ImageView 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_gravity="center" 

           android:src="@drawable/whatsapp" /> 

          <TextView 
           android:id="@+id/sharecodeWhatsapptext" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_gravity="center" 

           android:text="Whatsapp Invite" /> 

         </LinearLayout> 

         <LinearLayout 
          android:id="@+id/shareCodeFacebook" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginLeft="10dp" 
          android:layout_marginRight="10dp" 
          android:layout_marginTop="10dp" 
          android:background="@drawable/draw_login_edit_text" 
          android:gravity="center" 
          android:orientation="horizontal" 
          android:padding="10dp"> 

          <ImageView 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_gravity="center" 

           android:src="@drawable/fb_icon" /> 

          <TextView 
           android:id="@+id/sharecodefacebooktext" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_gravity="center" 

           android:text="Facebook Invite" /> 

         </LinearLayout> 

         <LinearLayout 
          android:id="@+id/shareCodeMore" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginBottom="10dp" 
          android:layout_marginLeft="10dp" 
          android:layout_marginRight="10dp" 
          android:layout_marginTop="10dp" 
          android:background="@drawable/draw_login_edit_text" 
          android:orientation="horizontal" 
          android:padding="10dp"> 

          <ImageView 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_weight="0.5" 
           android:src="@drawable/more_icon" /> 

          <TextView 
           android:id="@+id/sharecodemoretext" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_gravity="center" 
           android:layout_weight="0.5" 
           android:text="More Apps  " /> 

         </LinearLayout> 


        </LinearLayout> 


       </LinearLayout> 

       <Button 

        android:id="@+id/referCode" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/ll" 
        android:layout_centerInParent="true" 
        android:background="@drawable/item_view_add_to_cart_click" 
        android:text="YTH45T" 
        android:textColor="@color/white_bg" /> 


      </RelativeLayout> 


     </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 
+0

不....正在工作.... – stackover65

+0

我检查它是'正在工作......当您的设备需要滚动而不是滚动工作.....(意思是如果设备包含您的所有内容在第一个视图比滚动不工作,否则它是工作) –

0

删除的LinearLayout,使相对布局滚动型的直接孩子,它会开始滚动。