How to create a gridview like Foursquare interest selection screen?

不问归期 提交于 2019-12-06 02:05:21

You're looking for FlowLayout with gravity="center_horizontal". There are several implementations available, a lot of them as library projects on GitHub. Take you pick :)

ApmeM/android-flowlayout

blazsolar/FlowLayout

suanmiao/flowlayout

(descending *s)

This repo may will help someone. https://github.com/Cutta/TagView

Hello there is another example using custom Library which acts like List GitHubLibrary TagLayout

  • Sample Code:-

mFlowLayout.setAdapter(new TagAdapter<String>(mVals) { @Override public View getView(FlowLayout parent, int position, String s) { TextView tv = (TextView) mInflater.inflate(R.layout.tv, mFlowLayout, false); tv.setText(s); return tv; } });

Using below code you can pre set selection you wanted:-

mAdapter.setSelectedList(1,3,5,7,8,9);
amahfouz

You can try using a LinearLayout with gravity="center". If this does not work for you, then perhaps write your own custom layout that does the linear layout, wrapping, and centering.

For the former, see this post for an example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!