gpt4 book ai didi

java - 如何在代码中将 View 添加到线性布局的顶部?

转载 作者:太空狗 更新时间:2023-10-29 23:00:45 27 4
gpt4 key购买 nike

我需要在代码中将 admob adview 添加到线性布局,但我需要将其插入布局的顶部,而不是底部。

有办法吗?

最佳答案

使用:

public void addView (View child, int index) Since: API Level 1

Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child. Parameters child the child view to add index the position at which to add the child See Also

所以

yourLayout.addView(yourView, 0);

http://developer.android.com/reference/android/view/ViewGroup.html#addView(android.view.View,%20int )

关于java - 如何在代码中将 View 添加到线性布局的顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8270224/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com