我需要使用 java code
在 AbsoluteLayout
的底部设置 webview
的对齐方式,而不是xml布局 .
我尝试了一些Layoutparams组合,但它们没有用:
AbsoluteLayout al = (AbsoluteLayout) act.findViewById(R.id.ad);
WebView wv = new WebView(act);
wv.setScrollContainer(false);
wv.getSettings().setJavaScriptEnabled(true);
wv.setBackgroundColor(Color.TRANSPARENT);
String html = "<html><body style='margin:0;padding:0;'><script type='text/javascript' src='http://ad.leadboltads.net/show_app_ad.js?section_id=" + bannerId + "'></script></body></html>";
wv.loadData(html, "text/html", "utf-8");
al.addView(wv);
我无法编辑 xml layout
,我必须在代码中进行此操作 . 我不知道问题是否 AbsoluteLayout 已被弃用?或者我必须在底部设置webview而不是对齐 absolutelayout .
情况就是这样,我有一个填充屏幕的 Absolutelayout ,我想设置 webview 填充宽度(现在默认工作)并在底部对齐(默认情况下在顶部对齐)
我想要工作的xml是这样的:(我不能修改它)
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/${YYAndroidPackageName}"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<${YYAndroidPackageName}.DemoGLSurfaceView
android:id="@+id/demogl"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:id="@+id/ad" >
</AbsoluteLayout>
</FrameLayout>
对不起我的英文,谢谢你的帮助 .