Android 自定义 gridview 布局(顶部带有 imageview 的 textview) [英] Android custom gridview layout (textview with imageview on top)

查看:30
本文介绍了Android 自定义 gridview 布局(顶部带有 imageview 的 textview)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究如何为我的游戏创建网格视图的布局.我有一个 gridview,它将作为级别选择器.目前,我将每个 gridview 项目作为一个 TextView,只显示级别编号(1、2、3 等).

I'm trying to work out how to create the layout for a gridview for my game. I have a gridview which will be the level selector. At the moment I have each gridview item as a TextView, just showing the Level Number (1, 2, 3, etc).

我想在文本视图的顶部添加 3 个图像视图,并且能够操作视图中显示的图像.3 个图像视图是星星,显示关卡完成的难度.

I would like to add 3 imageviews over the top of the textview and be able to manipulate the image shown in the views. The 3 image views are stars, showing what difficulty the level was completed on.

我想我需要编写自己的适配器并在创建网格项的视图时扩展 XML 布局,但我一直在为如何为此创建实际布局而烦恼,重叠的部分让我摸不着头脑?

I figure I need to write my own Adapter and inflate the XML layout when creating the views for the grid items but I'm stuck with how to create the actual layout for this, the overlapping part has me scratching my head?

这是我试图描述的内容以及我想要创建的内容的模型:

Here's a mockup of what I've tried to describe, and what I want to create:

附注.我知道我可以使用 4 张图片并将 textview 背景设置为其中一张图片,但我想知道是否有更技术性的方法来创建布局.

PS. I know I could use 4 images and set the textview background to one of those images but I wondered if there was a more technical way of creating the layout.

推荐答案

最后我使用了非技术性的 4 张图片,它简单易行,滚动网格也没有任何问题,所以一切都很好.

I went with the un-technical 4 images in the end, it was simple and easy and there aren't any issues scrolling through the grid so it's all good.

这篇关于Android 自定义 gridview 布局(顶部带有 imageview 的 textview)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆