Im using a customized webview as follows
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:MyWebView="http://schemas.android.com/apk/res/com.mds.android.mireader.webview" android:background="#FFFFFF" android:layout_height="fill_parent" android:layout_width="fill_parent">
<com.mds.android.mireader.webview.MyWebView
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/myweb" **android:layout_width="318px"** android:layout_height="fill_parent" > </com.mds.android.mireader.webview.MyWebView>
im doing some thing strange, for that i need to satisfy following condition
condition: webview width should always divisible by 3
So i can’t give fixed value or fill_parent in above xml file.For example if i give fill_parent it works fine for portrait(assume HVGA emulator with portrait width=480 which is divisible by 3)but no success for landscape(bcz landscape width 800 which is not divisible by 3).
Solution should work for both orientation change and device change”
Im struggling with 1 or 2 pixel values difference and it will be solved if i satisfy that condition. TIA ….
HI,
You can get the height and width of the screen using following piece of code:
Now you have the width you can check whether it is divisible by 3 or not. If yes then well and good, otherwise you can subtract the modulus(width%3) from the original width and set it as the width of your webview.
Add A View Programmatically:
Sample XML:
Java Code:
PS: you dont have to add the webview object in your XML file. “addView” function will add your webview inside your linear layout object.
Hope this helps!!