表布局间距问题 [英] Table Layout spacing issues
本文介绍了表布局间距问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是表格布局。我想是同样的空间在屏幕左侧的垂直布局看到的图标(表格布局)present,从而覆盖整个屏幕的高度。我尝试了不同的方法,如layout_weight =1,设置图像宽度0dp,然后将体重......但其中没有任何帮助......
I am using a table layout. What i would want is to equally space the icons seen in the vertical layout(table layout) present on the left side of the screen, so as to cover the height of the whole screen. I tried out different methods like layout_weight="1", set the image width to 0dp and then set the weight...but none among them has helped.....
下面是XML ...
Here is the xml...
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp" >
<TableRow
android:layout_weight="1"
>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/XXX" />
</TableRow>
<TableRow
android:layout_weight="1"
>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Desserts"
/>
</TableRow>
<TableRow
android:layout_weight="1"
>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/sraberrydrink" />
</TableRow>
<TableRow
android:layout_weight="1"
>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Drinks"
android:textColor="#000000"
android:textSize="10dp" />
</TableRow>
<TableRow
android:layout_weight="1"
>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/newsoups" />
</TableRow>
<TableRow
android:layout_weight="1"
>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:text="Starters"
android:textColor="#000000"
android:textSize="10dp" />
</TableRow>
<TableRow
android:layout_weight="1" >
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="3dp"
android:background="@drawable/chipa" />
</TableRow>
<TableRow
android:layout_weight="1"
>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Snacks"
android:layout_marginLeft="45dp"
android:textColor="#000000"
android:textSize="10dp"/>
</TableRow>
</TableLayout>
如果有人可以指向一个解决方案....谢谢。
If someone could point to a solution....Thanks.
推荐答案
你可以做的是可以使用这样的线性布局
What you can do is can use a linear layout like this
!<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" android:background="#2e8b57" android:layout_weight=".8" android:gravity="center">
<LinearLayout
android:id="@+id/layout_main"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" android:layout_weight=".5">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_main"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" android:layout_weight=".5">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_main"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" android:layout_weight=".5">
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_main"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" android:layout_weight=".5">
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#8fbc8f" android:layout_weight=".2">
<LinearLayout
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" android:layout_weight=".8" android:gravity="center">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" android:layout_weight=".8" android:gravity="top|center">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
这篇关于表布局间距问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文