2012-10-04 221 views
1

我有一个LinearLayout,我比屏幕大。我想横向滚动。我有下一个代码,但它不起作用。有谁能够帮助我?如何水平滚动LinearLayout?

<HorizontalScrollView 
    android:id="@+id/horizontalScrollView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:id="@+id/gm_movimientos" 
     android:layout_width="wrap_content" 
     android:layout_height="50dp" 
     android:orientation="horizontal" > 

    </LinearLayout> 
</HorizontalScrollView> 
+0

所有okey最新问题? – MAC

+0

当线性布局大于屏幕时,我尝试水平滚动但没有任何事情发生。 – kudo44

+0

确保您检查布局上的包装。 –

回答

3

您的Horizo​​ntalScrollView宽度需要设置为match_parent或固定大小。现在ScrollView扩展到LinearLayout的相同尺寸(即其边界也离开屏幕)。

+0

我已经将Horizo​​ntalScrollView首先设置为match_parent,接下来是2000dp(确保它比LinearLayout大),但仍然不工作:( – kudo44

+1

Horizo​​ntalScrollView实际上需要小于LinearLayout。在可见大小边界内滚动 – Vyrx

+0

不,它不会工作,你可以定义宽度或高度大于设备宽度或高度,但它只会占用设备宽度或高度,而不是一个单一的dpi大于 – karn