• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Get effective size of a View object

hkproj

Lurker
May 3, 2011
1
0
Hi, I have a WebView. I would like to handle those touch who falls into a specific region of the WebView, for example the Rectangle [0, 0, 50, 200]...

I wrote the following code...

Code:
wvFirst.setOnTouchListener(new OnTouchListener() {

	public boolean onTouch(View view, MotionEvent event) {	
				
		Log.i("MyApplication", "Touch at: " + event.getX() + ", " + event.getY());
		return false;
	}
    		
});

The problem is that I would like to get the coordinate of the right-most rectangle(X, Y, Width, Height) [Width - 50, 0, 50, Height] of my WebView... but whenever I call the getWidth() or getHeight() I always get zero as result.

My WebView is declared in the xml:
HTML:
<WebView android:id="@+id/wvFirst" android:layout_width="fill_parent" android:layout_height="fill_parent">
</WebView>

Thank you.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones