是否可以将视图移动到 LinearLayout 中的最左下角?
Is it possible to move a view to the bottom-left-most corner in a LinearLayout?
所以,这是我的观点
使用 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TextView
style="?android:listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/crime_title_label" />
<EditText
android:id="@+id/crime_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/crime_title_hint" />
<TextView
style="?android:listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/crime_details_label" />
<Button
android:id="@+id/crime_date"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/crime_solved"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/crime_solved_label" />
</LinearLayout>
我想在最左下角添加一个按钮。但我不确定这是否可以在垂直方向的线性布局中实现。在不更改布局类型的情况下,我想到的唯一方法是将此部分添加到我想要的 Button:android:layout_gravity="bottom|left"
但这并不能解决问题。有什么建议么?如果能在线性布局中解决我会很高兴。
我认为这是最短的解决方案,尽管我想不出任何不包括附加布局的方法。将其添加到 xml 的末尾(仍在 LinearLayout 中)。
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</FrameLayout>
所以,这是我的观点
使用 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TextView
style="?android:listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/crime_title_label" />
<EditText
android:id="@+id/crime_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/crime_title_hint" />
<TextView
style="?android:listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/crime_details_label" />
<Button
android:id="@+id/crime_date"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/crime_solved"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/crime_solved_label" />
</LinearLayout>
我想在最左下角添加一个按钮。但我不确定这是否可以在垂直方向的线性布局中实现。在不更改布局类型的情况下,我想到的唯一方法是将此部分添加到我想要的 Button:android:layout_gravity="bottom|left"
但这并不能解决问题。有什么建议么?如果能在线性布局中解决我会很高兴。
我认为这是最短的解决方案,尽管我想不出任何不包括附加布局的方法。将其添加到 xml 的末尾(仍在 LinearLayout 中)。
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</FrameLayout>