开发者

Android layout: combining LinearLayout and TableLaout

开发者 https://www.devze.com 2023-03-27 00:00 出处:网络
I would like to have a layout that looks like this (in landscape mode): - on top 4 equally spaced button

I would like to have a layout that looks like this (in landscape mode): - on top 4 equally spaced button - in middle: an EditText block and next to it on its right an ImageButton - at the bottom a textview.

Here is the xml file that I used to implement this layout:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:padding="20dip"
>


<TableLayout 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*">

<TableRow>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/b1"
android:drawablePadding="5sp"
android:text="B1"></Button>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/b2"
android:drawablePadding="5sp"
android:text="B2"></Button>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/b3"
android:drawablePadding="7sp"
android:text="B3"></Button>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/b4"
android:drawablePadding="7sp"
android:text="B4"></Button>

</TableRow>   
</TableLayout> 

<TableLayout 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*">

<TableRow>

<EditText 
android:id="@+id/entry"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_below="@id/e1"
android:layout_marginLeft="20dp" 
android:layout_marginTop="10dp"  
/开发者_如何学C>
<ImageButton
android:id="@+id/search2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/i1" 
android:layout_marginTop="10dp" 
/>  

</TableRow>

<TextView
android:id="@+id/t2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="T2"/>

</TableLayout> 

</LinearLayout> 

However, what I say is 4 buttons on top the way I want, and the rest (second row and third row) is not on the page (cannot be seen). I don't know where they have gone. I appreciate any help for this. Thanks,

TJ


Add

android:orientation="vertical" 

in parent LinearLayout.

0

精彩评论

暂无评论...
验证码 换一张
取 消