【发布时间】:2012-08-12 11:39:07
【问题描述】:
在我的应用程序中,我使用了gridview,textview 是gridview 的一个项目。列数 = 3,在此如何为所有列提供相等的宽度。 谁能帮帮我?
我的代码是:
网格视图: .........
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center" >
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MyGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:gravity="center_horizontal"
android:horizontalSpacing="5dp"
android:numColumns="3"
android:padding="5dp"
android:columnWidth="100dp"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp" >
</GridView>
</LinearLayout>
网格项目:
<TextView
android:id="@+id/grid_item_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:background="@drawable/btn_selected"
android:gravity="center_horizontal|center_vertical"
android:text="TextView"
android:textColor="@color/BLACK"
android:textSize="14dp" >
</TextView>
</LinearLayout>
【问题讨论】:
-
文本将从db动态流出。
-
是的,我明白了。我已经为 textview 呈现的布局提供了“fill_parent”。并且没有为网格视图分配宽度。
标签: android gridview column-width