简体   繁体   English

如何根据android中的项目管理gridview

[英]How can I manage gridview according to widht of items in android

I have to manage gridview as below. 我必须管理gridview,如下所示。 Please sugges how can I manage gridview as it is image. 请建议我如何管理gridview,因为它是图像。

在此输入图像描述

I am using following xml code 我正在使用以下xml代码

 <GridView
            android:id="@+id/tags_dialog_list"
            android:layout_width="match_parent"
            android:layout_height="@dimen/dialog_internal_list_height"
            android:layout_marginTop="2dp"
            android:choiceMode="singleChoice"
            android:horizontalSpacing="@dimen/tags_grid_item_divider_size"
            android:numColumns="auto_fit"
            android:layout_marginLeft="@dimen/tags_grid_item_divider_size"

            android:verticalSpacing="@dimen/tags_grid_item_divider_size" />

Your picture is not a grid. 你的照片不是网格。 A grid would look completely symmetrical like a chess board. 网格看起来像棋盘一样完全对称。 What you have in your picture is a flow layout . 你的图片中有一个流程布局

There are some open source flow layout solutions such as ApmeM/android-flowlayout and blazsolar/FlowLayout , but your picture is even more interesting since the lines are fill justified , which I don't think either of these layouts can do. 有一些开源流程布局解决方案,如ApmeM / android- flowlayoutblazsolar / FlowLayout ,但你的图片更有趣,因为线条是填充对齐的 ,我不认为这些布局都可以做到。 You will probably need to write your own layout. 您可能需要编写自己的布局。

You should look at the flow layout code for the basics, but you will need to add some logic that takes all the items in the line and expands them proportionately until the left and right sides are even and all the inner spaces are equal. 您应该查看基本的流程布局代码,但是您需要添加一些逻辑来获取行中的所有项目并按比例扩展它们,直到左侧和右侧均匀并且所有内部空间相等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM