android GridView android:stretchMode="columnWidth"

stretchMode屬性值的作用是設置GridView中的條目以什麼縮放模式去填充空間。參數stretchMode 可選值:NO_STRETCH,STRETCH_SPACING,STRETCH_SPACING_UNIFORM,或STRETCH_COLUMN_WIDTH


<GridView android:id="@+id/grid"  
android:layout_width="fill_parent"  
android:layout_height="fill_parent"  
android:verticalSpacing="35px" <!-- grid元素之間的豎直間隔 -->  
android:horizontalSpacing="5px" <!--grid元素之間的水平間隔 -->  
android:numColumns="auto_fit" <!--表示有多少列,如果設置爲auto_fit,將根據columnWidth和Spacing來自動計算 -->  
android:columnWidth="100px" <!-- 一般建議採用有像素密度無關的dip或者dp來表示-->  
android:stretchMode="columnWidth" <!--如何填滿空餘的位置,模擬器採用WVGA800*480,每排4列,有4*100+5*3=415,還餘65px的空間,如果是columnWidth,則這剩餘的65將分攤給4列,每列增加16/17px。如果採用SpacingWidth,則分攤給3個間隔空隙 -->  
android:gravity="center" />   


發佈了141 篇原創文章 · 獲贊 166 · 訪問量 111萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章