android - Layout dont fit Screensize -


I have a device with 540 pix screen sizes (width). I try this layout:

  endline: Android: Orientation = "horizontal" Android: layout_height = "fill_parent" Android: layout_width = "540dp" & gt;  

But the linear layout is larger than the screen. It's out of the screen.

I read the screen through the screen:

  DisplayMetrics displaymetrics = new display metrics (); . GetWindowManager () getDefaultDisplay () getMetrics (displaymetrics). Int width = displaymetrics.widthPixels;  

More tools, so the screen is definitely 540 pix width.

What's wrong? The actual unit is 'PX', whereas the unit you use in your layout file is 'DP'.

- The difference between the two is that the values ​​given in 'DP' are scaled by the device. Setting your value in 540 px should solve your problem.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -