[android-developers] Re: WebView - can't set its position..

2013-07-07 Thread AmitNHB
Please ignore this line: 


*webView**.setVisibility(View.GONE**);*

I'm setting it back to visible later on and like I said, the view starts at the 
very top instead of at 120.


On Monday, July 8, 2013 3:59:37 AM UTC+3, AmitNHB wrote:

 Hello, I feel this should be very basic but I can't seem to be able to set 
 the position of a WebView. I have a my surface (which extends SurfaceView) 
 and an AdView at the bottom and now I want to add a WebView and position it 
 at a certain height on the screen. I do this, trying to position my web 
 view at the center:

 webView = new WebView(this);
 webView.setWebViewClient(new WebViewClient());
 webView.setVisibility(View.GONE);LayoutParams webViewParams = new 
 LayoutParams(800,240);
 webViewParams.setMargins(0, 120, 800, 360); 


 And the last line doesn't seem to have any effect as the view starts at the 
 very top.

 I also tried using the gravity field and setting it to GRAVITY.CENTER and it 
 did not matter.

 Here's the full code: 
 (I'm using a device with a 800X480 resolution and I'm in landscape more, and 
 for now 
 I'm just trying to position my webview at the center taking up half the 
 display' space.)

 *
 **private MySurface surface;private AdView adView;private WebView
 ...
 // create the ad view
 adView = new AdView(this, AdSize.SMART_BANNER, AD_MOB_ID);
 adView.setAdListener(new MyAdListener());
 // create the surface
 surface = MySurface.getRef(this);
 // set a listener for touch event
 surface.setOnTouchListener(this);
 // create the web view
 webView = new WebView(this);
 webView.setWebViewClient(new WebViewClient());LayoutParams webViewParams = 
 new LayoutParams(800,240); // this works
 webViewParams.setMargins(0, 120, 800, 360); // this does 
 nothing...
 // create a relative layoutRelativeLayout l = new RelativeLayout(this);
 // add the surface
 l.addView(surface);
 // add the ad view at the bottomAdView.LayoutParams adViewParams = new 
 AdView.LayoutParams(AdView.LayoutParams.WRAP_CONTENT,AdView.LayoutParams.WRAP_CONTENT);

 adViewParams.addRule(AdView.ALIGN_PARENT_BOTTOM);

 l.addView(adView, adViewParams);

 l.addView(webView, webViewParams);

 setContentView(l);  
 // load an ad//loadAdMob(); *

 *  *

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: WebView - can't set its position..

2013-07-07 Thread AmitNHB
OK, got it:

*webView = new WebView(this);
webView.setWebViewClient(new WebViewClient());RelativeLayout.LayoutParams 
webViewParams= new RelativeLayout.LayoutParams(800, 240);
webViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);*



On Monday, July 8, 2013 3:59:37 AM UTC+3, AmitNHB wrote:

 Hello, I feel this should be very basic but I can't seem to be able to set 
 the position of a WebView. I have a my surface (which extends SurfaceView) 
 and an AdView at the bottom and now I want to add a WebView and position it 
 at a certain height on the screen. I do this, trying to position my web 
 view at the center:

 webView = new WebView(this);
 webView.setWebViewClient(new WebViewClient());
 webView.setVisibility(View.GONE);LayoutParams webViewParams = new 
 LayoutParams(800,240);
 webViewParams.setMargins(0, 120, 800, 360); 


 And the last line doesn't seem to have any effect as the view starts at the 
 very top.

 I also tried using the gravity field and setting it to GRAVITY.CENTER and it 
 did not matter.

 Here's the full code: 
 (I'm using a device with a 800X480 resolution and I'm in landscape more, and 
 for now 
 I'm just trying to position my webview at the center taking up half the 
 display' space.)

 *
 **private MySurface surface;private AdView adView;private WebView
 ...
 // create the ad view
 adView = new AdView(this, AdSize.SMART_BANNER, AD_MOB_ID);
 adView.setAdListener(new MyAdListener());
 // create the surface
 surface = MySurface.getRef(this);
 // set a listener for touch event
 surface.setOnTouchListener(this);
 // create the web view
 webView = new WebView(this);
 webView.setWebViewClient(new WebViewClient());LayoutParams webViewParams = 
 new LayoutParams(800,240); // this works
 webViewParams.setMargins(0, 120, 800, 360); // this does 
 nothing...
 // create a relative layoutRelativeLayout l = new RelativeLayout(this);
 // add the surface
 l.addView(surface);
 // add the ad view at the bottomAdView.LayoutParams adViewParams = new 
 AdView.LayoutParams(AdView.LayoutParams.WRAP_CONTENT,AdView.LayoutParams.WRAP_CONTENT);

 adViewParams.addRule(AdView.ALIGN_PARENT_BOTTOM);

 l.addView(adView, adViewParams);

 l.addView(webView, webViewParams);

 setContentView(l);  
 // load an ad//loadAdMob(); *

 *  *

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.