android - 按钮的样式正在添加未知属性 - Android

标签 android android-layout android-button android-layout-weight

我正在尝试实现 Facebook Activity 页面的外观,但在复制他们的三个按钮时遇到了问题,这些按钮表明某人是否要参加 Activity 。

我正在努力实现这一目标,

enter image description here

我的目前看起来是这样的,

enter image description here

这是按钮的 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>

我不知道按钮上方和下方的额外 PaddingMargin 在哪里。我在按钮上尝试了 android:padding="0dp"android:layout_margin="0dp" 但没有效果。

我最好的猜测是它可能与 layout_weight 属性有关。这可能会根据按钮的宽度为按钮提供一定的高度,如果是这种情况,我该如何使按钮更短?

最佳答案

当您应用背景 item_left_button_background 时,它必须是一个图像或包含具有特定高度的图像的选择器。当您将按钮高度设置为 wrap_content 时,默认情况下它会采用图像的高度,因此根据我的建议为按钮指定特定高度或根据您需要的尺寸创建背景图像

关于android - 按钮的样式正在添加未知属性 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30182463/

相关文章:

Android:如何设置PreferenceActivity的Preference自定义布局的ImageView

android - 将页眉/页脚添加到 GridView

java - 制作按钮时,在范围内无法访问类型 MainActivity 的封闭实例

android - 设置 android 按钮不可见但仍然附加了一个 onClick 监听器

android - Android 3.0及以上版本无法从res中获取xml数据

c# - 最近有没有在 ScrollView 中移动 map (xamarin.forms.maps)的解决方案?

android - 更新 fragment 不起作用

android - 如何以原始比例设置自定义单选按钮android的背景图像?

javascript - 如何使用 JavaScript 将值从一个 HTML 页面传递到另一个页面?

android - 特定内容的 GTM 屏幕 View 跟踪