Android 按钮的非等宽线内布局相对线内布局

Android 按钮的非等宽线内布局相对线内布局,android,android-layout,Android,Android Layout,我不明白,为什么按钮的大小不一样。早些时候,我使用LinearLayout而不是RelativeLayout作为根,但经过一些谷歌搜索后,我明白了,没有机会使用LL创建页脚,所以我将其设置为RL,并通过使用按钮将以前的LL调整为RL,但是 我也不明白,为什么RL中的边距无论如何都不起作用(我从下面的代码中删除了),以及我如何在RL中为元素留边距 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:androi

我不明白,为什么按钮的大小不一样。早些时候,我使用LinearLayout而不是RelativeLayout作为根,但经过一些谷歌搜索后,我明白了,没有机会使用LL创建页脚,所以我将其设置为RL,并通过使用按钮将以前的LL调整为RL,但是

我也不明白,为什么RL中的边距无论如何都不起作用(我从下面的代码中删除了),以及我如何在RL中为元素留边距

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>

    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/linearLayout_buttons" >

    </ListView>

</RelativeLayout>

刚刚设置好

android:layout_width="0dp"
而不是

android:layout_width="wrap_content"
在您的按钮中,使权重发挥作用(技巧!)

还可以在线性布局中设置android:orientation=“horizontal”

刚刚设置

android:layout_width="0dp"
而不是

android:layout_width="wrap_content"
在您的按钮中,使权重发挥作用(技巧!)

还可以在线性布局中设置android:orientation=“horizontal”

刚刚设置

android:layout_width="0dp"
而不是

android:layout_width="wrap_content"
在您的按钮中,使权重发挥作用(技巧!)

还可以在线性布局中设置android:orientation=“horizontal”

刚刚设置

android:layout_width="0dp"
而不是

android:layout_width="wrap_content"
在您的按钮中,使权重发挥作用(技巧!)


还可以在线性布局中设置
android:orientation=“horizontal”
您可以使用LL:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:orientation="vertical">

    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

    </ListView>

    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>

</LinearLayout>


如果要使按钮的宽度相同,请将按钮的宽度更改为“匹配父项”。

您可以使用LL:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:orientation="vertical">

    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

    </ListView>

    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>

</LinearLayout>
Try this way,hope this will help you to solve your problem.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>


    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>
</LinearLayout>


如果要使按钮的宽度相同,请将按钮的宽度更改为“匹配父项”。

您可以使用LL:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:orientation="vertical">

    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

    </ListView>

    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>

</LinearLayout>
Try this way,hope this will help you to solve your problem.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>


    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>
</LinearLayout>


如果要使按钮的宽度相同,请将按钮的宽度更改为“匹配父项”。

您可以使用LL:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:orientation="vertical">

    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

    </ListView>

    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>

</LinearLayout>
Try this way,hope this will help you to solve your problem.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>


    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>
</LinearLayout>

如果要使按钮的宽度相同,请将按钮的宽度更改为“匹配父项”。

试试这种方法,希望这能帮助您解决问题。
Try this way,hope this will help you to solve your problem.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <ListView
        android:id="@+id/listView_mentions"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>


    <LinearLayout
        android:id="@+id/linearLayout_buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button_add"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Add" />

        <Button
            android:id="@+id/button_delete"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/all_mentions_Delete" />
    </LinearLayout>
</LinearLayout>
试试这种方法,希望这能帮助您解决问题。
试试这种方法,希望这能帮助您解决问题。
试试这种方法,希望这能帮助您解决问题。

0dp如何帮助我?为什么纯重量=1没有这样做?0dp对我有什么帮助?为什么纯重量=1没有这样做?0dp对我有什么帮助?为什么纯重量=1没有这样做?0dp对我有什么帮助?O_O为什么纯重量=1没有这样做?我试图在RL内设置边距。这并不能使孩子成为边缘人。例如,我试着在RL内设置边距。这并不能使孩子成为边缘人。例如,我试着在RL内设置边距。这并不能使孩子成为边缘人。例如,我试着在RL内设置边距。这并不能使孩子成为边缘人。举个例子,当一个元素有权重而另一个元素没有权重时,LL发生了什么?这是否意味着“没有重量的元素将填满没有其他元素的所有空间”?当一个元素有重量而另一个元素没有重量时,LL发生了什么?这是否意味着“没有重量的元素将填满没有其他元素的所有空间”?当一个元素有重量而另一个元素没有重量时,LL发生了什么?这是否意味着“没有重量的元素将填满没有其他元素的所有空间”?当一个元素有重量而另一个元素没有重量时,LL发生了什么?这是否意味着“没有重量的元素将填充没有其他元素的所有空间”?