1

I've been digging around for a while about this issue. In my layout, I have a textview. How do I make the width of my textview's width half of the screen's physical width? Can I do it in the xml layout directly or I should have a function in the java code,which gets the physical size and set the textview's size one half of that? I don't care abou the resolution.

Thanks in advance!

checai
  • 836
  • 4
  • 11
  • 17
  • I guess you need this: http://stackoverflow.com/questions/6794141/androidlayout-height-50-of-the-screen-size – mvp Nov 25 '12 at 06:58

1 Answers1

2

You should use the layout_wheight attribute for yout TextView:

Android:layout_width="0dp"
Android:layout_weight=1

Use the same property (and same weight) on the layout you want to place on the side of your TextView, they will have both the same size = 1/2 of your physical screen.

Waza_Be
  • 39,407
  • 49
  • 186
  • 260