Android中的间距按钮

Abel Pule英语

我有2个按钮的布局,但它们并排连接,如何在它们之间放置间隙或间隔。当我单击时如何使按钮改变颜色

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="30dp" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="20dp" >
    <Button
        android:id="@+id/login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.40"
        android:background="#FF55FF"
        android:text="Login"
        android:textColor="#FFFFFF" />
    <Button
        android:id="@+id/register"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.40"
        android:background="#FF55FF"
        android:text="Register"
        android:textColor="#FFFFFF" />
</LinearLayout>

m0rpheu5

我刚刚将按钮的layout_margin设置为5dp。根据您的要求进行选择

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:padding="30dp" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:paddingTop="20dp" >
            <Button
                android:id="@+id/login"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="0.40"
                android:background="#FF55FF"
                android:text="Login"
                android:layout_margin="5dp"
                android:textColor="#FFFFFF" />
            <Button
                android:id="@+id/register"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="0.40"
                android:background="#FF55FF"
                android:text="Register"
                android:layout_margin="5dp"
                android:textColor="#FFFFFF" />
        </LinearLayout>
        </LinearLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在 bootstrap 按钮组中划分间距

来自分类Dev

在RecyclerView Android中删除项目之间的间距

来自分类Dev

Boostrap 4 间距,为什么按钮没有版本 3 中的垂直间距?

来自分类Dev

如何在QToolBar中控制QAction按钮的间距?

来自分类Dev

想在android中的CardView卡片之间添加水平间距?

来自分类Dev

垂直HTML按钮间距问题

来自分类Dev

如何在Sencha Touch中的vbox布局中设置按钮之间的间距

来自分类Dev

有没有办法更改cordova-plugin-dialogs上的Android按钮的间距?

来自分类Dev

Android中按钮的边框

来自分类Dev

Android中的圆形按钮

来自分类Dev

在android中滑动按钮?

来自分类Dev

在Android中禁用按钮

来自分类Dev

Android中的按钮对齐

来自分类Dev

为什么向行中的按钮添加左浮点会导致它们之间的间距改变?

来自分类Dev

Swift-如何在水平StackView中的可变数量的按钮之间设置间距?

来自分类Dev

为什么在行中向按钮添加左浮点会导致它们之间的间距改变?

来自分类Dev

iOS中的字母间距

来自分类Dev

HTML中的表格间距

来自分类Dev

UILabel中的单词间距

来自分类Dev

HTML中的间距元素

来自分类Dev

Java中的间距元素

来自分类Dev

脚注中的间距

来自分类Dev

单选按钮的垂直间距不均匀

来自分类Dev

在 Bootstrap 按钮行之间添加间距

来自分类Dev

Android中的脉动按钮动画

来自分类Dev

在Android中隐藏按钮栏

来自分类Dev

Android中刷新按钮的动画

来自分类Dev

耳机按钮在Android中双击

来自分类Dev

FrameLayout中的Android按钮布局