[英]android linearlayout not align right
我有一個看起來像這樣的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/menu_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorBackgroundFloating"
android:minWidth="600dp"
app:contentInsetStart="0dp"
android:elevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="end">
<Button
android:id="@+id/confirm_button"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="Confirm"
android:textAllCaps="false" />
<Button
style="?android:attr/buttonBarStyle"
android:id="@+id/reset_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="Reset"
android:textAllCaps="false" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/prefer_tags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" />
<FrameLayout
android:id="@+id/exclude_tags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" />
</LinearLayout>
確認按鈕和重置按鈕應該在工具欄的右側。 但是,它們僅存在於FrameLayout
,除非FrameLayout
存在某些內容( prefer_tags
或exclude_tags
)。 你可以從下面的圖片中看到:
如何始終將按鈕保持在右側?
嘗試更換
android:layout_width="match_parent"
機器人:重力=“結束”
到
android:layout_width="wrap_content"
機器人:layout_gravity="結束"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.