在android中设置imageview和两个按钮之间的间距

在android中设置imageview和两个按钮之间的间距,android,android-layout,Android,Android Layout,我有一个布局,其中有一个ImageView和两个按钮。现在我想在ImageView和两个按钮之间设置空间 XML <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView

我有一个布局,其中有一个
ImageView
和两个
按钮
。现在我想在
ImageView
和两个
按钮之间设置空间

XML

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <ImageView
                android:id="@+id/companyLogo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight=".1"
                android:layout_gravity="left"
                android:adjustViewBounds="true"
                android:background="@mipmap/ic_launcher" />
            <Button
                android:id="@+id/clear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right|center"
                android:gravity="right|center"
                android:text="Clear" />

            <Button
                android:id="@+id/add"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right|center"
                android:gravity="right|center"
                android:text="Apply" />
        </LinearLayout>

我试着设定体重,但对我无效。请在这方面帮助我。


<View
    android:clickable="true"
    android:layout_gravity="center"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1" />
在ImgaeViews和按钮之间写入此视图。 它将起作用

您可以使用,或在布局中使用类的实例在视图之间添加一些空间。您没有指定所需的结果,因此请选择适合您需要的内容。

顺便说一句,
Space
View
类相比是这个任务更好的选择,因为它被设计成一个轻量级的间隔小部件,并且不像普通的
View
那样进行一些计算。

尝试添加
android:layou margin=“20dp”


只需在ImageView的左右两侧添加一些边距即可。
        <ImageView
            android:id="@+id/companyLogo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".1"
            android:layout_margin="20dp"
            android:layout_gravity="left"
            android:adjustViewBounds="true"
            android:background="@mipmap/ic_launcher" />
android:layout_marginTop="20dp" / 
android:layout_marginLeft="20dp"/
android:layout_marginBottom="20dp" /
android:layout_marginRight="20dp"