Reputation:
I've been finding the way to make the buttons right-aligned, but wasn't successful. Need a little help here.
<LinearLayout android:id="@+id/categoryRowLayout"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:text="category" android:id="@+id/categoryRow"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</TextView>
<Button android:text="Edit" android:id="@+id/editCategoryBtn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:onClick="editCategoryHandler">
</Button>
<Button android:text="Delete" android:id="@+id/deleteCategoryBtn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:onClick="deleteCategoryHandler">
</Button>
</LinearLayout>
Screenshot:
Upvotes: 0
Views: 240
Reputation: 10348
As an alternative, you could have just added to your TextView:
android:layout_weight="1"
Upvotes: 0
Reputation: 29121
<RelativeLayout android:id="@+id/categoryRowLayout"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:text="category" android:id="@+id/categoryRow"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</TextView>
<Button android:text="Edit" android:id="@+id/editCategoryBtn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:onClick="editCategoryHandler"
android:layout_toLeftOf="@+id/deleteCategoryBtn"
>
</Button>
<Button android:text="Delete" android:id="@+id/deleteCategoryBtn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:onClick="deleteCategoryHandler"
android:layout_alignParentRight="true"
>
</Button>
</RelativeLayout>
Try this, i have used relative layout and aligned delete button to right and edit button to the left of delete button.
Upvotes: 2