繁体   English   中英

是否可以将视图移动到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>  

我想在最左下角添加一个按钮。 但是我不确定在垂直方向的线性布局中是否可以实现。 我想到的唯一不更改布局类型的方法就是将这部分添加到我想要的按钮中: 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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM