Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在xml中为这个FAB提供相等的空间?_Android_Xml_Android Layout_Floating Action Button - Fatal编程技术网

Android 如何在xml中为这个FAB提供相等的空间?

Android 如何在xml中为这个FAB提供相等的空间?,android,xml,android-layout,floating-action-button,Android,Xml,Android Layout,Floating Action Button,请找到图片 这是我的布局XML:我正在为我的应用程序编写这段代码 有人能告诉我为什么它不起作用吗 任何建议都会有帮助 最好从官方文件中学习。来了 文件: 定义最大权重和。如果未指定,则总和由以下公式计算: 添加所有子项的布局权重。这可以用于 实例为单个子对象提供总可用空间的50% 将布局_权重设置为0.5,并将权重总和设置为1.0 可以是浮点值,例如“1.2” 文件: 指示在LinearLayout中分配了多少额外空间 指向与这些布局参数关联的视图。如果视图不可用,请指定0 不应该被拉伸。

请找到图片

这是我的布局XML:我正在为我的应用程序编写这段代码


有人能告诉我为什么它不起作用吗 任何建议都会有帮助


最好从官方文件中学习。来了

文件:

定义最大权重和。如果未指定,则总和由以下公式计算: 添加所有子项的布局权重。这可以用于 实例为单个子对象提供总可用空间的50% 将布局_权重设置为0.5,并将权重总和设置为1.0

可以是浮点值,例如“1.2”

文件:

指示在LinearLayout中分配了多少额外空间 指向与这些布局参数关联的视图。如果视图不可用,请指定0 不应该被拉伸。否则,额外像素将按比例分配 在所有权重大于0的视图中

可以是浮点值,例如“1.2”


这是因为FloatingActionButton只能具有固定大小

您可以在它们之间添加一些空间

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="2">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="5dp"
android:paddingEnd="5dp">

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/download_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/download"
app:backgroundTint="@android:color/white" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="5dp"
android:paddingEnd="5dp">

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/download_btn1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/download"
app:backgroundTint="@android:color/white" />

</LinearLayout>
</LinearLayout>

你必须使用不同的东西

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >

  <LinearLayout
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:gravity="center_horizontal"
      >

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        .../>

  </LinearLayout>

  <LinearLayout
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:gravity="center_horizontal"
      >
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        .../>
  </LinearLayout>

</LinearLayout>


问题出在哪里。。?请详细描述该项目Question@BADSHAH请查看此问题顶部的图像链接您希望结果如何..?底部线性布局中的晶圆厂等距制作线性布局android:layout_alignParentEnd=“true”@badsah
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >

  <LinearLayout
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:gravity="center_horizontal"
      >

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        .../>

  </LinearLayout>

  <LinearLayout
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:gravity="center_horizontal"
      >
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        .../>
  </LinearLayout>

</LinearLayout>