如何将视图添加到在code的线性布局的顶部? [英] How to add a view to the top of a linear layout in code?

查看:123
本文介绍了如何将视图添加到在code的线性布局的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个admob的AD浏览添加到code进行线性布局,但我需要的布局,而不是底部的顶部以将其插入。

I need to add an admob adview to a linear layout in code but I need to insert it at the top of the layout, not the bottom.

有没有办法做到这一点?

Is there a way to do this?

推荐答案

使用:

公共无效addView(查看孩子,INT指数)自:API级别1

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

添加一个子视图。如果没有布局参数上已经设置   子,默认参数为此的ViewGroup是对孩子设置。   参数child子视图添加索引的位置上   添加孩子另请参见

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);

<一个href="http://developer.android.com/reference/android/view/ViewGroup.html#addView(android.view.View,%20int">http://developer.android.com/reference/android/view/ViewGroup.html#addView(android.view.View,%20int)

这篇关于如何将视图添加到在code的线性布局的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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