1

I need set the align of a webview in the bottom of a AbsoluteLayout using java code, no the xml layout.

I tried some Layoutparams combinations, but they didnt work:

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

I cant edit the xml layout, I have to make this in code. I dont know if the problem is that AbsoluteLayout is deprecated? Or I have to set the webview in bottom instead the align the absolutelayout.

The situation is this, I have a Absolutelayout that fill the screen, and I want set the webview fill the width (this working by default now) and aligns in bottom (by default aligns in top)

The xml over I want to work is this: (I cant modify it)

<?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>

Sorry my english, thanks for the help.

Genaut
  • 1,810
  • 2
  • 29
  • 60
  • 1
    ok but why absolute layout u wanna use? – KOTIOS Aug 24 '14 at 13:35
  • I have that implement ads on a framework, and I cant have edit the xml resource, only modify in runtime with code. :S – Genaut Aug 24 '14 at 13:36
  • ok , so u hv to restrictly use absolute? or its not behaving? from above code whats the result how is it loking? – KOTIOS Aug 24 '14 at 13:38
  • With the above code, the webview loads nice, but set their align to the top of screen. Yes, I have to restrict to use absolutelayout. This the more clean code that I have for post – Genaut Aug 24 '14 at 13:46
  • ok what if i wanna try at my end the above code is enough? any xml part u wanna add? – KOTIOS Aug 24 '14 at 13:48
  • do not use AbsoluteLayout, use FrameLayout instead (for example) – Yuraj Aug 24 '14 at 13:57
  • I edited with the base xml for the layout. I cant edit the xml file. Only edit the align with java code – Genaut Aug 24 '14 at 14:00

0 Answers0