2014-10-07 71 views
-1

我有一個ScrollView裏面的滾動ListView的問題嘗試了下面給出的代碼。如何設置垂直滾動ScrollView在另一個垂直滾動窗口部件(ListView)

<?xml version="1.0" encoding="utf-8"?> <LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/linlaypromodet" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 
     <LinearLayout 
      android:id="@+id/linearlayoutheaderpromo" 
      android:layout_width="fill_parent" 
      android:layout_height="80dp" 
      android:orientation="horizontal" 
      android:gravity="center_vertical" 
      android:background="@drawable/dairam_header2"> 

      <Button 
       android:id="@+id/buttonbackhomepromodet" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back_arrow" 
       android:layout_marginLeft="3dp"/> 


      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="80dp"> 
        <TextView 
         android:id="@+id/textviewheaderpromodete" 
         android:layout_width="wrap_content" 
         android:layout_height="80dp" 
         android:textColor="#fff" 
         android:layout_marginLeft="4dp" 
         android:gravity="center" 
         android:textAppearance="?android:attr/textAppearanceLarge" /> 

        <Button 
         android:id="@+id/buttonsharepromodet" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentRight="true" 
         android:layout_marginTop="30dp" 
         android:layout_marginRight="10dp" 
         android:background="@drawable/shareicon" /> 
        </RelativeLayout> 
     </LinearLayout> <ScrollView 
        android:id="@+id/scrollView1" 
        android:layout_width="fill_parent" 
        android:layout_height="0dp" 
        android:layout_alignParentLeft="true" 
        android:layout_below="@+id/buttoncartpromodet" 
        android:layout_weight="2" 
        android:layout_marginTop="5dp" > <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:maxHeight="100dp" > 

      <com.dairam.viewpager.AutoScrollViewPager 
       android:id="@+id/imageView1" 
       android:layout_width="fill_parent" 
       android:layout_height="200dp" 
       android:layout_alignParentLeft="true" 
       android:minHeight="100dp" 
       android:layout_alignParentTop="true"/> 

      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignBottom="@+id/imageView1" 
       android:layout_alignParentLeft="true" 
       android:layout_marginBottom="75dp" > 

       <Button 
        android:id="@+id/buttonleftarrow" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="5dp" 
        android:layout_alignParentLeft="true" 
        android:background="@drawable/arrow_leftgray" /> 

       <Button 
        android:id="@+id/buttonrightarrow" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_marginRight="5dp" 

        android:background="@drawable/arrow_rightgray" /> 
      </RelativeLayout> 



     </RelativeLayout> 




       <LinearLayout 
        android:id="@+id/rellay" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" > 

     <RelativeLayout android:id="@+id/toplay" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center_vertical"> 
      <Button android:id="@+id/viewbtn" 
        android:layout_width="fill_parent" 
        android:layout_height="2dp" 
        android:layout_marginTop="5dp" 
        android:background="@drawable/dividergray"/> 

      <Button 
       android:id="@+id/buttoncartpromodet" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_alignParentRight="true" 
       android:layout_centerHorizontal="true" 
       android:layout_marginRight="5dp" 
       android:background="@drawable/redicon"/> 

      <Button 
       android:id="@+id/buttonwishlistpromodet" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="8dp" 
       android:layout_toLeftOf="@+id/buttoncartpromodet" 
       android:background="@drawable/greenicon" /> 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignBaseline="@+id/buttonwishlistpromodet" 
       android:layout_alignBottom="@+id/buttonwishlistpromodet" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="5dp" 
       android:textColor="#000"/> 
      <ScrollView 
        android:id="@+id/scrollViewdesc" 
        android:layout_width="fill_parent" 
        android:layout_height="0dp" 
        android:layout_alignParentLeft="true" 

        android:layout_weight="1" 
        android:layout_marginTop="5dp" > <ListView 
     android:id="@+id/textViewdescription" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/textView1" 
     android:layout_marginTop="5dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginBottom="10dp" 

    > 

    </ListView> </ScrollView> 


       <Button android:id="@+id/dividerbtm" 
         android:layout_height="2dp" 
         android:layout_width="fill_parent" 
         android:background="@drawable/dividergray" 
         android:layout_alignBottom="@+id/textViewdescription" 
         android:layout_marginTop="5dp"/> 



     </RelativeLayout> 





     <TextView 
      android:id="@+id/textviewsuggestion" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:text="YOU MAY ALSO LIKE" 
      android:textColor="#000" 
      android:textSize="20sp" /> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="wrap_content" 
      android:layout_height="100dp" 
      android:layout_marginTop="10dp" 
      android:background="#fff" > 
     </android.support.v4.view.ViewPager> 

      </LinearLayout> 
     </LinearLayout> 
     </ScrollView> 
     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="60dp" 
      android:layout_marginTop="5dp" 
      android:orientation="vertical" > 


      <View android:layout_height="1dp" 
       android:layout_width="fill_parent" 
       android:background="@drawable/dividergray" 
       android:layout_marginTop="6dp"/> 
      <Button 
       android:id="@+id/buttonamntpromodet" 
       android:layout_width="100dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentLeft="true" 
       android:layout_marginRight="8dp" 
       android:textColor="#fff" 
       android:background="@drawable/redbox" /> 

      <Spinner 
       android:id="@+id/buttonquantitypromodet" 
       android:layout_width="100dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:textColor="#fff" 
       android:spinnerMode="dropdown" 
       android:gravity="center" 
       android:paddingLeft="10dp" 
       android:layout_alignParentRight="true" 
       android:background="@drawable/greybox2" /> 

      <TextView 
       android:id="@+id/textView2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/buttonquantitypromodet" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginTop="3dp" 
       android:text=" Quantity" 
       android:gravity="center" 
       android:textColor="#fff" 
       android:textAppearance="?android:attr/textAppearanceSmall" /> 

     </RelativeLayout> 

</LinearLayout> 

回答

0

你做錯了什麼(據我所知)是把listView放在一個ScrollView中。 ListView本身是不可滾動的,所以scrollview是不必要的。

我過去曾經遇到過問題,它既不會導致滾動....也許這是您的問題。

另外,我不知道它只是如何發佈的代碼,但你不應該開始一個按鈕的佈局....我相信它需要在一個佈局標籤內設置。

0

請從上面刪除滾動視圖Listview因爲Listvie本身可滾動。