[英]TableLayout: Buttons have to stick together without leaving any space
I done a Tab Bar.It displays at the bottom of the screen.Then I created five buttons.That was displayed at the bottom of the screen above the tab bar. 我完成了一个标签栏,它显示在屏幕底部,然后创建了五个按钮,显示在标签栏上方的屏幕底部。
You can see the image below: 您可以看到下图:
main.xml: main.xml中:
<?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" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="5" >
</FrameLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BOOKS" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LIBRARY" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MATH" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MUSEUM" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+24" />
</TableRow>
</TableLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
</LinearLayout>
My problem is Buttons have to stick together without leaving any space.Anybody can help me with these.Thank you. 我的问题是Button必须贴在一起而不留任何空间,任何人都可以帮助我,谢谢。
There is Tricky Solution For it... 有棘手的解决方案...
You Just Have to Set Negative Margins For it.... 您只需要为此设置负边距即可 。
Just set the android:layout_marginRight
of the first button to "-7dip" or even more. 只需将第一个按钮的
android:layout_marginRight
设置为“ -7dip”甚至更多即可。
Try Code Something like below... Set Margins As Your Need 尝试编写类似于以下内容的代码...根据需要设置边距
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-7dip"
android:text="BOOKS" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-7dip"
android:text="LIBRARY" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-7dip"
android:text="MATH" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-7dip"
android:text="MUSEUM" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-7dip"
android:text="+24" />
</TableRow>
</TableLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.