2016-06-21 65 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,使相對佈局滾動型的直接孩子,它會開始滾動。