Created
July 15, 2015 06:01
-
-
Save r17171709/4cc1515b02cfa1901052 to your computer and use it in GitHub Desktop.
gridlayout动态添加
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//类似数组[行, 列] | |
//表示起始位置为0,占据2行 | |
GridLayout.Spec rowSpec=GridLayout.spec(0, 2, GridLayout.UNDEFINED); | |
//表示起始位置为1,占据1列 | |
GridLayout.Spec columnSpec=GridLayout.spec(i, 1, GridLayout.UNDEFINED); | |
GridLayout.LayoutParams params=new GridLayout.LayoutParams(rowSpec, columnSpec); | |
gridlayout.addView(view, params); | |
此外xml中也要预先定好多少行多少列 | |
<android.support.v7.widget.GridLayout | |
android:id="@+id/gridlayout" | |
app:rowCount="10" | |
app:columnCount="6" | |
android:background="@mipmap/ic_chat_bg" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
</android.support.v7.widget.GridLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment