简体   繁体   中英

Remove space between buttons

i have bunch of buttons within linear layout. But there is spaces buttons. I set padding as 0 but there no change. There is someone who already had the same problem at http://www.mail-archive.com/android-developers@googlegroups.com/msg51104.html but no answer at there. Can you plese help me.

Try to play with android:layout_margin attribute. For instance, to reduce space on the left/right side (assuming you have a horizontal set of buttons) you can do smth like this:

<Button
    android:layout_marginLeft="-3dip"
    android:layout_marginRight="-3dip"
    ... />

I'll refer you to a previous answer I gave on this:

If you're meaning you want them to be pushed to the edge, pixel for pixel, you'll need to use your own 9-patch for the button background, as the default one in Android has a few extra pixels around the border of its 9-patch background. For an example of this, look at the file in your SDK folder under:

platforms/android-8/data/res/drawable-hdpi/btn_default_transparent_normal.9.png

For example, this is what I get with the default:

替代文字

And with a custom 9-patch I had made earlier:

替代文字

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