简体   繁体   中英

how to remove button space alocated for text drawableTop

在此输入图像描述

<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> 

is there a way to make my icon wrap content?to take out the space below for text disregard the space on left and right i need those space for icon space between each other but i don't need space below and above image how can i take it out.i was able to take out the space above but i cant take out the space below how can i do this?

Yes, you can remove the space at the bottom of the button using perfect height of button like android:layout_height="40dip"

Lyaout Code

<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"
/>

Graphical Layout

在此输入图像描述

If you want a button that only contains an image (and no text), you should use an ImageButton :

<ImageButton
    android:id="@+id/profile"
    style="@style/DashboardButton"
    android:src="@drawable/abarprofile"/>

You could also try to use margin such as

<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"
/>

By doing this way, the negative sign actually remove the spaces by the button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM