0

在此处输入图像描述

<Button
        android:id="@+id/profile"
        style="@style/DashboardButton"
        android:drawableTop="@drawable/abarprofile"/>



 <style name="DashboardButton">
        <item name="android:layout_gravity">center_vertical</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:paddingLeft">10dp</item>
        <item name="android:paddingRight">10dp</item>
        <item name="android:background">@null</item>
    </style> 

有没有办法让我的图标换行内容?取出下面的空间用于文本忽略左右的空间我需要这些空间用于彼此之间的图标空间,但我不需要图像上下的空间我怎么能把它拿出来。我能把上面的空间拿出来,但我不能把下面的空间拿出来怎么办?

4

3 回答 3

2

是的,您可以使用完美的按钮高度来删除按钮底部的空间,例如 android:layout_height="40dip"

代码

<Button
android:id="@+id/tvQuickContactCall"
android:layout_width="wrap_content"
android:layout_height="40dip"
android:layout_marginRight="15dip"
android:background="@android:color/transparent"
android:drawableTop="@drawable/ic_call"
android:layout_weight="1"
/>

图形布局

在此处输入图像描述

于 2013-07-11T01:35:23.033 回答
0

如果您想要一个仅包含图像(不包含文本)的按钮,则应使用ImageButton

<ImageButton
    android:id="@+id/profile"
    style="@style/DashboardButton"
    android:src="@drawable/abarprofile"/>
于 2013-07-11T01:38:00.747 回答
0

您也可以尝试使用边距,例如

<Button
    android:id="@+id/btnButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="-10dip"
    android:layout_marginRight="-10dip"
    android:layout_marginTop="-10dip"
    android:layout_marginLeft="-10dip"
/>

通过这种方式,负号实际上删除了按钮的空格。

于 2013-07-11T03:06:34.353 回答