我需要在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