Adwhirl 与底部对齐
我有一个屏幕,其中有 2 个全屏视图,并且我想要在底部有一个广告旋转广告。
这是我的 xml 文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:id="@+id/main_layout"
>
</RelativeLayout>
然后我通过代码将视图放在上面:
// in activity's onCreate
RelativeLayout layout = (RelativeLayout)findViewById(R.id.main_layout);
v1= new V1(this);
v2= new V2(this, v1);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
v1.setLayoutParams(lp);
v2.setLayoutParams(lp);
layout.addView(v1);
layout.addView(v2);
.....
AdWhirlLayout adWhirlLayout2 = new AdWhirlLayout(this, "key");
adWhirlLayout2.setAdWhirlInterface(this);
adWhirlLayout2.setMaxWidth(width);
adWhirlLayout2.setMaxHeight(height);
RelativeLayout.LayoutParams lp_bottom = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp_bottom.addRule(RelativeLayout.ALIGN_BOTTOM, RelativeLayout.TRUE);
adWhirlLayout2.setLayoutParams(lp_bottom);
layout.addView(adWhirlLayout2);
但广告仍然位于屏幕顶部,就像我没有设置布局参数时一样。
I have a screen where i have 2 fullscreen views, and i want an adwhirl ad at the bottom.
Here is my xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:id="@+id/main_layout"
>
</RelativeLayout>
Then i put the views on it from code:
// in activity's onCreate
RelativeLayout layout = (RelativeLayout)findViewById(R.id.main_layout);
v1= new V1(this);
v2= new V2(this, v1);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
v1.setLayoutParams(lp);
v2.setLayoutParams(lp);
layout.addView(v1);
layout.addView(v2);
.....
AdWhirlLayout adWhirlLayout2 = new AdWhirlLayout(this, "key");
adWhirlLayout2.setAdWhirlInterface(this);
adWhirlLayout2.setMaxWidth(width);
adWhirlLayout2.setMaxHeight(height);
RelativeLayout.LayoutParams lp_bottom = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp_bottom.addRule(RelativeLayout.ALIGN_BOTTOM, RelativeLayout.TRUE);
adWhirlLayout2.setLayoutParams(lp_bottom);
layout.addView(adWhirlLayout2);
But the ads are still at the top of the screen, like when i didn't set the layoutparams.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 :
Try :