如何摆脱的按钮和其他视图之间多余的差距? [英] How to get rid of the extra gap between a button and other views?

查看:114
本文介绍了如何摆脱的按钮和其他视图之间多余的差距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建了一个按钮来查看,机器人总是创建这个按钮,它下面的其他视图之间的一些额外的空间。

在下面这个例子中,存在的第二个按钮上方的按钮。你可以看到这两个按钮之间的差距。我怎样才能摆脱这种差距?谢谢你。

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT>

    <按钮机器人:ID =@ + ID /向上
        机器人:layout_width =FILL_PARENT机器人:layout_height =28DIP
        机器人:TEXTSIZE =9SP安卓重力=中心的android:文本=隐藏某事
        机器人:layout_marginBottom =0的android:paddingBottom会=0/>
    <按钮机器人:ID =@ + ID /下
        机器人:layout_width =FILL_PARENT机器人:layout_height =28DIP
        机器人:TEXTSIZE =9SP安卓重力=中心的android:文本=显示某事/>
   < / LinearLayout中>
 

解决方案

创建自己的按钮背景九补丁PNG,消除了空间。你可以找到现有的背景文件,在你的SDK。

When I created a button view, Android always create some extra space between this button and other views below it.

In this example below, there is a button above the second button. You can see the gap between these two buttons. How can I get rid of this gap? Thanks.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <Button android:id="@+id/up"
        android:layout_width="fill_parent" android:layout_height="28dip"
        android:textSize="9sp" android:gravity="center" android:text="Hide sth"
        android:layout_marginBottom="0" android:paddingBottom="0" />
    <Button android:id="@+id/down"
        android:layout_width="fill_parent" android:layout_height="28dip"
        android:textSize="9sp" android:gravity="center" android:text="Show sth" />
   </LinearLayout>

解决方案

Create your own button background nine-patch PNG that eliminates the space. You can find the existing background files in your SDK.

这篇关于如何摆脱的按钮和其他视图之间多余的差距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆