Grid view like Windows 8 or Google Play

本小妞迷上赌 提交于 2020-01-13 19:27:11

问题


I'm looking for the source code, or an example, of a gridview. I know that with eclipse i can do something really simple: many squares next to each other.

But i want to have something strange and particular like this example:

Click here

Someone can help me?


回答1:


You can use StaggerdGridview from Here Github

It Looks Like This




回答2:


You can do it through layout nesting. It's basically just like doing your html pages. For example:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="226dp"
            android:background="@color/dark_shadow">
    </LinearLayout>

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

        <LinearLayout
                android:orientation="vertical"
                android:layout_width="180dp"
                android:layout_height="fill_parent"
                android:background="@color/holo_bright_blue">
        </LinearLayout>

        <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                >

            <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="fill_parent"
                    android:layout_height="154dp"
                    android:background="@color/me_blue">
            </LinearLayout>

            <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent">

                <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="106dp"
                        android:layout_height="fill_parent"
                        android:background="@color/dark_shadow">
                </LinearLayout>

                <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:background="@color/light_gray">
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

    </LinearLayout>
</LinearLayout>

Also make use of the layout weight and weight sum of the parent container is you need to add other views inside those layouts. Hope this will give you some hints on what you're trying to achieve.



来源:https://stackoverflow.com/questions/18689636/grid-view-like-windows-8-or-google-play

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