<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="3dip"
    tools:context=".MainActivity" >    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="今日概况:" />
        />
    
     <TableLayout 
       android:layout_width="fill_parent"     
       android:layout_height="wrap_content"
       android:stretchColumns="*"
        android:padding="3dip"
        >
    
    <TableRow>
         
   <ImageButton
 android:id="@+id/button1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:src ="@drawable/st0"
/>

   <ImageButton
 android:id="@+id/button2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:src ="@drawable/st1"

 />  
   </TableRow>
   
      <TableRow>
         
   <ImageButton
 android:id="@+id/button3"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:src ="@drawable/st0"
/>

   <ImageButton
 android:id="@+id/button4"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:src ="@drawable/st1"

 />  
   </TableRow>
    </TableLayout></LinearLayout>上面是我的布局代码
 <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="今日概况:" />
        />
如果这样写,后面4个ImageButton不会显示<TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="今日概况:" />
        />
如果是这样,后面4个ImageButton  可以显示,但跟TextView 是在同一行,怎样可以把4个ImageButton  放到下一行  并且能整体居中   谢谢!

解决方案 »

  1.   


    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:padding="3dip"
        tools:context=".MainActivity" >    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="今日概况:" />
        </LinearLayout>    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:layout_weight="1">
            <ImageButton
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/st0" />
            <ImageButton
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/st1" />
            <ImageButton
                android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/st0" />
            <ImageButton
                android:id="@+id/button4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/st1" />
        </LinearLayout></LinearLayout>