更改线性布局android中的视图顺序 [英] change order of views in linear layout android

查看:13
本文介绍了更改线性布局android中的视图顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如您所知,线性布局中的视图顺序与它们在 xml 文件中的顺序有关.是否可以通过索引之类的方式使用 Java 代码更改该顺序?

As you know the order of views in linear layout is related to the order of them in xml file. Is it possible to change that order with java code by something like indexing?

推荐答案

我会尝试使用 removeView(view) 并将它们添加到 addView(childView, index) 按照你喜欢的顺序.

I would try to remove all views with removeView(view) and add them with addView(childView, index) in that order you like.

这篇关于更改线性布局android中的视图顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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