Guest User

Untitled

a guest
Feb 11th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. What I'm looking for is a button right on the left with the textview centered in the remaining space:
  2. | text button|
  3. (| shows edge of screen)
  4.  
  5. What happens is this:
  6. |text button|
  7.  
  8. <!-- This LL fills the screen width. -->
  9. <LinearLayout
  10. android:layout_width="match_parent"
  11. android:layout_height="wrap_content"
  12. android:orientation="horizontal" >
  13. <!-- This LL gets all the space to the left of the button due to weight 1 -->
  14. <LinearLayout
  15. android:layout_width="0dip"
  16. android:layout_height="match_parent"
  17. android:layout_weight="1"
  18. android:orientation="horizontal" >
  19.  
  20. <!-- This textview is always on the hard left -->
  21. <!-- no matter what layout_gravity is specified -->
  22. <TextView
  23. android:id="@+id/result_textview"
  24. android:layout_width="wrap_content"
  25. android:layout_height="wrap_content"
  26. <!-- center_vertical works as it should... -->
  27. android:layout_gravity="center_horizontal|center_vertical"
  28. android:text="testtest"
  29. android:textAppearance="?android:attr/textAppearanceLarge" />
  30.  
  31. </LinearLayout>
  32.  
  33. <!-- This button is on the right edge of the screen as it should be -->
  34. <!-- due to default weight 0 -->
  35. <Button
  36. android:layout_width="wrap_content"
  37. android:layout_height="wrap_content"
  38. android:text="@string/calculate_string"
  39. android:onClick="myFunction" />
  40. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment