2
我正在嘗試構建一個屏幕,其寬度爲180px,並附加到屏幕的右側。我面臨的問題是,gridview的背景會繪製整個屏幕,而不僅僅是我在XML中指定的180px(因此會阻止我在LinearLayout中指定的背景圖片)。Android:Gridview無法正確顯示
既不使用重量也不使用重力解決問題。
看起來很簡單,但我一直玩這個小時無濟於事。在此先感謝您的幫助。
我layout.xml如下:在您的GridView
聲明
android:stretchMode="none"
:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_bkgd">
<GridView
android:layout_height="fill_parent"
android:scrollbars="none"
android:numColumns="1"
android:columnWidth="180px"
android:verticalSpacing="6dp"
android:layout_width="wrap_content"
android:id="@+id/mainmenu_grid"
android:gravity="right"
android:fadingEdge="vertical"
android:layout_gravity="right"
android:background="#000000"
android:layout_weight=".35">
</GridView>
</LinearLayout>
謝謝。固定寬度到190是不可能的。甚至不需要使用Stretch Mode ... – MikeC 2011-04-19 12:51:00
使用strechmode會更清潔,但是 – njzk2 2011-12-02 14:19:02