Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.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
Java LinearLayout用相同的填充物放置三个按钮_Java_Android - Fatal编程技术网

Java LinearLayout用相同的填充物放置三个按钮

Java LinearLayout用相同的填充物放置三个按钮,java,android,Java,Android,我想将三个浮动动作按钮放置在一行中,并使用相同的填充。结果应该是这样的。(来自iOS谷歌翻译应用程序) 但现在看起来是这样的:(中间的捕获晶圆厂将是隐形的) 这是我的布局文件: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" an

我想将三个浮动动作按钮放置在一行中,并使用相同的填充。结果应该是这样的。(来自iOS谷歌翻译应用程序)

但现在看起来是这样的:(中间的捕获晶圆厂将是隐形的)

这是我的布局文件:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto" >

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/relativeLayoutCamera2">

        <TextureView
            android:id="@+id/textureView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <LinearLayout
            android:gravity="bottom"
            android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:id="@+id/baseline"
            android:weightSum="3"
            android:background="@color/strapGrey">

            <android.support.design.widget.FloatingActionButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:id="@+id/browseImagesFAB"
                android:src="@drawable/ic_photo_library_white_24dp"
                app:elevation="0dp"
                android:layout_weight="1"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                app:backgroundTint="@color/strapGrey"
                app:fabSize="mini"/>

            <android.support.design.widget.FloatingActionButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:id="@+id/captureInvisible"
                android:src="@drawable/ic_photo_camera_white_24dp"
                app:fabSize="mini"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                app:backgroundTint="@color/strapGrey" />

            <android.support.design.widget.FloatingActionButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:id="@+id/flashFAB"
                android:src="@drawable/ic_flash_off_white_24dp"
                app:elevation="0dp"
                android:layout_weight="1"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                app:backgroundTint="@color/strapGrey"
                app:fabSize="mini"/>

        </LinearLayout>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/captureImageFAB"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/fab_margin"
            android:src="@drawable/ic_photo_camera_white_24dp"
            app:fabSize="normal"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true" />

    </RelativeLayout>

</android.support.design.widget.CoordinatorLayout>

我试过设置android:layout\u weight,正如你在那里看到的,但它就是不起作用。请帮忙


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="match_parent"
tools:context="com.vzw.www.myapplication.MainActivity"
android:gravity="center">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="5dp">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button 1"
        android:layout_weight="0.33"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button 1"
        android:layout_weight="0.33"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button 1"
        android:layout_weight="0.33"/>


</LinearLayout>

这将使此>


而且,它们不一定是按钮。您可以对ImageView或TextView执行相同的操作。

这是实现设计的一个非常简单的示例

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.design.widget.FloatingActionButton
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_gravity="bottom|center_horizontal" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/bottom_nav_height"
    android:layout_gravity="bottom"
    android:background="#757575"
    android:weightSum="3">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/iv_nav_voucher"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_gravity="center"
            android:clickable="false"
            android:focusableInTouchMode="false"
            android:src="@drawable/ic_launcher" />
    </LinearLayout>

    <View
        android:id="@+id/nav_center"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="horizontal"></View>

    <LinearLayout
        android:id="@+id/nav_other"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/iv_nav_other"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:clickable="false"
            android:focusableInTouchMode="false"
            android:src="@drawable/ic_launcher" />
    </LinearLayout>
</LinearLayout>


简单的回答是,
FloatingActionButton
不能很好地处理线性布局。尝试改用
CircleImageView
。我可以问一下@dimen/bottom\u nav\u height的值是多少吗?啊。只是底部导航的默认高度:56dp。将其更改为56dp或任何您想询问的值。如果第一个线性布局基本上是两个图像视图所在的导航栏,那么视图对象应该是什么?它只是一个假视图,以确保父视图包含3个宽度相同的视图。