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:
<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.
作为替代方案,您可以刚刚添加到TextView中:
android:layout_weight="1"
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.