2013-03-09 118 views
1

我有ListView比父視圖更寬。要進行水平滾動,我使用Horizo​​ntalScrollView將其包裝。Android ListView。垂直滾動條總是不可見的寬列表

簡化佈局XML:

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

    <RelativeLayout 
     android:id="@+id/main" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <ListView 
      android:id="@+id/children" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      /> 
    </RelativeLayout> 
</HorizontalScrollView> 

所以我有在Horizo​​ntalScrollView的ListView和水平滾動條垂直滾動條。

我的問題是,我沒有看到垂直列表滾動條,除非Horizo​​ntalScrollView沒有滾動到最右邊的位置。因爲垂直滾動條沿着ListView的右邊緣。

有沒有辦法讓垂直滾動條沿Horizo​​ntalScrollView的右邊緣可見? 使列表垂直滾動條在任何Horizo​​ntalScrollView位置都可見。

+0

你有沒有找到解決這個問題呢?我遇到了與我的應用程序中的組件相同的問題。如果有一個內置的方式來保持垂直條總是可見的,我想利用它。 – frenziedherring 2013-12-26 19:19:57

+0

不幸的是我沒有找到解決方案:( – 2013-12-28 21:37:30

回答

1

試試這個:

<HorizontalScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scrollbars="none"> 

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

        <ListView android:id="@+id/children" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" /> 
     </LinearLayout> 
</HorizontalScrollView> 
+0

謝謝你的回答。 我試過了你的代碼,但沒有幫助。:(結果只有水平滾動條消失了。 – 2013-03-10 15:23:09