0

I have created a view (actually a webview):

<WebView
  android:id="@+id/myWebView"
  android:layout_width="match_parent"
  android:layout_height="@dimen/input_height"
/>

Which refers to the height in another xml file:

<resources>
    <dimen name="key_height">50dip</dimen>
    <dimen name="candidate_font_height">16sp</dimen>
    <dimen name="candidate_vertical_padding">6sp</dimen>
    <dimen name="input_height">280dip</dimen>
</resources>

Where I have set the input_height as 280dip which I understand to mean 280 pixels (device independently) of an approximately 320 pixel (or emulated 320ish pixel) height.

On my two devices (small sony ericsson xperia x10 mini with 320 pixel screen, and old htc desire), it works fine, providing a view height of approximately 1.3 of the screen height. One of my testers is using a samsung galaxy S and they are reporting that the view takes up more than the entire screen.

I assume the issue is something to do with screen density, but I thought using dip would circumvent that issue.

How should I define my layout view to avoid this problem?

Billy Moon
  • 57,113
  • 24
  • 136
  • 237

2 Answers2

0

You could detect the size of the screen and then do some math to get 1/3 the screen size. To detect the screen size, take a look at this.

Community
  • 1
  • 1
user1585542
  • 35
  • 10
0

before that you need to find out the width and height of the screen by following the method shown here at : Get screen dimensions in pixels

YOu need to use layoutparams to set the parameters to your layout dynamically. Look here : http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html

set the layout parameters to whatever you want to

Community
  • 1
  • 1
Android2390
  • 1,150
  • 12
  • 21