如何使线性布局具有水平滚动功能

4

我的应用程序包含不同的布局,其中一个是线性布局。它的内容是动态添加的。我想让这个布局可以水平滚动。为此,我将我的布局放在了滚动视图中。但是仍然无法滚动...以下是我的代码:

 <LinearLayout android:id="@+id/scoreballparent_layout"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
   android:layout_width="fill_parent"
  android:layout_above="@+id/score_layout">
  <ScrollView android:layout_height="wrap_content" 
  android:id="@+id/scrollView1" 
  android:layout_width="fill_parent" 
  >
      <LinearLayout android:layout_width="fill_parent" 
      android:id="@+id/scoreball_layout" 
      android:layout_height="wrap_content"
      android:isScrollContainer="true" 
      android:scrollbars="horizontal">

         </LinearLayout>
     </ScrollView>
</LinearLayout>

请注意,如果内容适合屏幕,则滚动条将不会出现。 - Axel M. Garcia
2个回答

10

请使用HorizontalScrollView代替。

同时,当内容无法适应布局区域时,您的布局将变为可滚动。


谢谢...但是有一件事...在滚动时它显示滚动条,我不想显示它...并且当向此布局添加新内容时,我希望自动滚动布局...你能帮我吗? - star angel

0

只需要在xml中使用这个 android:fadeScrollbars="true" 可能会对你有用


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接