【问题标题】:Unknown space to the right of the grid view网格视图右侧的未知空间
【发布时间】:2010-08-09 07:13:30
【问题描述】:

我的xml代码是:

    <GridView android:id="@+id/gridView_calendar"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:layout_weight="1" android:numColumns="5"/>

但是gridView的右边出现了一个空白。它的大小似乎是滚动条。我不知道它是怎么来的。有谁能够帮我?谢谢!

【问题讨论】:

    标签: android gridview scroll android-layout space


    【解决方案1】:

    已经解决了。这是 GridView 的剩余空间。

    设置屏幕宽度为totalX。 gridView 节点宽为 deltaX,网格数为 n,则未知空间为: totalX - deltaX*n。

    但是有没有 api 可以避免这个空间?

    【讨论】:

      【解决方案2】:
      android:stretchMode="spacingWidthUniform"
      

      或任何其他拉伸模式,请参阅: http://developer.android.com/reference/android/widget/GridView.html#attr_android:stretchMode

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-25
        • 1970-01-01
        • 2018-01-21
        • 1970-01-01
        • 1970-01-01
        • 2014-02-16
        相关资源
        最近更新 更多