微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Button的风格是添加未知属性 – Android

我试图实现Facebook的活动页面的外观,并且我在复制他们的三个按钮时遇到问题,这些按钮说明一个人是否要参加活动.

我想要实现这一点,

我的目前看起来像这样,

这是按钮的XML

<LinearLayout
        android:id="@+id/button_holder"
        android:layout_alignParentBottom="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="3"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:paddingBottom="10dp">

        <Button
            android:id="@+id/button_going"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textSize="14sp"
            android:textColor="@color/secondary_text"
            android:text="Going"
            android:background="@drawable/item_left_button_background"/>

        <Button
            android:id="@+id/button_maybe"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textSize="14sp"
            android:textColor="@color/secondary_text"
            android:text="Maybe"
            android:background="@drawable/item_middle_button_background"/>

        <Button
            android:id="@+id/button_decline"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textSize="14sp"
            android:textColor="@color/secondary_text"
            android:text="Decline"
            android:background="@drawable/item_right_button_background"/>

    </LinearLayout>

我不知道在我的按钮上方和下方有多余的填充或边距.我在按钮上尝试了android:padding =“0dp”和android:layout_margin =“0dp”,但它没有效果.

我最好的猜测是它可能与layout_weight属性有关.这可能会根据宽度给按钮一定的高度,如果是这种情况,那么如何缩短按钮呢?

解决方法

当您应用背景item_left_button_background时,必须是包含图像的图像或选择器,这些图像具有特定高度.当您将按钮高度设置为wrap_content时,认情况下将采用图像的高度,以便根据我的建议为按钮指定特定高度或根据您所需的尺寸创建背景图像

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐