Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- What I'm looking for is a button right on the left with the textview centered in the remaining space:
- | text button|
- (| shows edge of screen)
- What happens is this:
- |text button|
- <!-- This LL fills the screen width. -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
- <!-- This LL gets all the space to the left of the button due to weight 1 -->
- <LinearLayout
- android:layout_width="0dip"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="horizontal" >
- <!-- This textview is always on the hard left -->
- <!-- no matter what layout_gravity is specified -->
- <TextView
- android:id="@+id/result_textview"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- <!-- center_vertical works as it should... -->
- android:layout_gravity="center_horizontal|center_vertical"
- android:text="testtest"
- android:textAppearance="?android:attr/textAppearanceLarge" />
- </LinearLayout>
- <!-- This button is on the right edge of the screen as it should be -->
- <!-- due to default weight 0 -->
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/calculate_string"
- android:onClick="myFunction" />
- </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment