我需要在Android应用程序中创建自己的工具栏。 现在看起来像这样:删除LinearLayout中的按钮间距(Android)
所以你看到按钮之间的空间。我试图在按钮上放置负边距/填充,但空间并未消失。
这里是布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/routes_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5">
</ListView>
<TableRow
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="0dp" >
<Button
android:id="@+id/btn_routes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:text="@string/routes"
android:textSize="10dp" />
<Button
android:id="@+id/btn_places"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:textSize="10dp"
android:text="@string/places" />
<Button
android:id="@+id/btn_events"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:textSize="10dp"
android:text="@string/events" />
<Button
android:id="@+id/btn_about"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:text="@string/about"
android:textSize="10dp" />
</TableRow>
</LinearLayout>
如何按钮之间移除空间?
也许你可以检查此 - HTTP:/ /stackoverflow.com/questions/2277732/how-to-get-rid-of-the-extra-gap-between-a-button-and-other-views – 2012-02-26 09:32:28
这个想法是使用具有相同背景色的ImageButtons。 – hovanessyan 2012-02-26 09:37:06