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!
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.