Android如何实现基于箭头的布局?

标签 android android-recyclerview staggered-gridview staggeredgridlayout staggeredgridlayoutmanager

我想知道如何实现这样的基于箭头的布局:

enter image description here enter image description here enter image description here enter image description here

知道什么 Layout 使用此应用程序来实现该布局吗?看起来像是一种交错网格布局?或者也许正在使用库或自定义布局?我怎样才能实现类似的目标?

最佳答案

所以这就是我将如何做这样的事情。

我制作了一堆自定义 View 。

自定义 View #1: 口袋妖怪 View 。 这是一个常规的 Constraint Layout 或 CardView,其中包含用于显示 pokemon 及其名称和所有其他内容的所有项目。

自定义 View #2 EvolutionPokeminView。 这是一个自定义约束布局,其中包含一个 PokemonView、The Arrow ImageView(和下面的 TextView)以及将箭头放置在不同方向的辅助方法。

例如: setArrowDirection(int direction)\direction 是所有方向的某种枚举(top, topLeft, topRight..等

另一个辅助方法是 setArrorPosition, setArrowPosition(int 方向)

然后使用箭头方向方法将正确的箭头图像设置到 arrowImageView 中,然后使用箭头位置方法使用 ConstraintSet 以编程方式设置箭头相对于宠物小 Sprite 图片。

之后,您准备一些通用布局以用于不同的数据集并相应地填充它们。

要使此方法奏效,您需要知道的事情。 如何在 Android 中制作自定义 View 。 如何有效地使用 ConstraintLayout。 如何使用 ConstraintSet 以编程方式编辑 ConstraintLayout 约束。

关于Android如何实现基于箭头的布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63727158/

相关文章:

android - 在 RecyclerView 中使用 onClick() 启动新 Activity

android - StaggeredLayout 与 FlexboxLayoutManager

Android:如何创建类似 Facebook 的图片库网格?

android - Etsy 的 StaggeredGridview 是否可以在 API 9 中工作?

android - 允许用户在 Recyclerview Android 中仅选择 1 项

android - RecyclerView 的 GridLayoutManager 动态跨度计数

java - 没有在 Selenium + Appium 上获取动态 ListView 的所有元素

java - 如何检查 Firebase Firestore 事务是否已更新到服务器?

android - 如何将项目发送到 Kotlin.Flow(如 Behaviorsubject)

android - 如果 "Embedded Google assistant SDK"已被释放?