This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to give Edittext and button to half of the screen width?  RSS feed

 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
below is my login screen.I need to give both EditText and Button to take half of the screen width.can we archive this using weight ?unless i have to give margin values specifically for each type of screens(small,large,...)?

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Weights only work with LinearLayout. For a perfect 50/50 split in a RelativeLayout you can put a view centered in the layout, then put your views to the left and right of the strut. Something like this:


You can adjust the spacing more or less than 50/50 by putting a left margin on the space. Example:

 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Steve
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!