2013-07-18 69 views
0

enter image description here平等垂直间隔的列布局

我想让我的我的应用程序的主屏幕上的这个布局。 我有上面显示的每个图像块的条纹。 请指导我使用哪种布局(RelativeLayout,LinearLayout ...等)来实现此目的。 我是新来的android开发。我尝试了一些布局,但没有成功。我也用过FrameLayout

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:stretchColumns="1"> 

     <TableRow> 
      <FrameLayout 
       android:id="@+id/inboxLargeButton" 
       android:layout_height="wrap_content" 
       android:layout_width="0dp" 
       android:layout_weight="1"> 

       <ImageView android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/inbox_normal" 
        android:id="@+id/buttonWeddingDayCheatSheet" 
        android:layout_gravity="center_horizontal"> 
       </ImageView> 
       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="2631" 
        android:layout_gravity="bottom" 
        android:gravity="center" 
        android:textColor="#fff" 
        android:textSize="50dp" /> 
      </FrameLayout> 

      <FrameLayout 
       android:layout_height="wrap_content" 
       android:layout_width="0dp" 
       android:layout_weight="1"> 
       <ImageView android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/outbox_normal" 
        android:id="@+id/buttonShareFavoriteRecipe" 
        android:layout_gravity="center_horizontal"> 
       </ImageView> 
       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="0296" 
        android:layout_gravity="bottom" 
        android:gravity="center" 
        android:textColor="#fff" 
        android:textSize="50dp" /> 
       </FrameLayout> 
     </TableRow> 

     <TableRow> 
      <FrameLayout 
       android:layout_height="wrap_content" 
       android:layout_width="0dp" 
       android:layout_weight="1"> 

       <ImageView android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/header_left_normal" 
        android:id="@+id/buttonWeddingDayCheatSheet" 
        android:layout_gravity="center_horizontal"> 
       </ImageView> 
       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Most sent" 
        android:layout_gravity="bottom" 
        android:gravity="center" 
        android:textColor="#fff" 
        android:textSize="15dp" /> 
      </FrameLayout> 

      <FrameLayout 
       android:layout_height="wrap_content" 
       android:layout_width="0dp" 
       android:layout_weight="1"> 
       <ImageView android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/header_right_normal" 
        android:id="@+id/buttonShareFavoriteRecipe" 
        android:layout_gravity="center_horizontal"> 
       </ImageView> 
       </FrameLayout> 
     </TableRow> 
     <TableRow> 
      <FrameLayout 
       android:layout_height="wrap_content" 
       android:layout_width="0dp" 
       android:layout_weight="1"> 

       <ImageView android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/body_left_normal" 
        android:id="@+id/buttonWeddingDayCheatSheet" 
        android:layout_gravity="center_horizontal"> 
       </ImageView> 
      </FrameLayout> 

      <FrameLayout 
       android:layout_height="wrap_content" 
       android:layout_width="0dp" 
       android:layout_weight="1"> 
       <ImageView android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/body_right_normal" 
        android:id="@+id/buttonShareFavoriteRecipe" 
        android:layout_gravity="center_horizontal"> 
       </ImageView> 
       </FrameLayout> 
     </TableRow> 
    </TableLayout> 

因为我想让每个块都可以点击。

+0

您的问题没说清楚,但可能与'机器人:stretchColumns = “1”' – njzk2

+0

它已经在那里,机器人:stretchColumns = “1” – UsmanAzam

+0

是,这就是我所说的。如果你想要统一分发 – njzk2

回答

0

试试这个代码:

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:stretchColumns="1" > 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <LinearLayout 
      android:id="@+id/inboxLargeButton" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <ImageView 
       android:id="@+id/buttonWeddingDayCheatSheet" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:src="@drawable/ic_launcher" > 
      </ImageView> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:gravity="center" 
       android:text="2631" 
       android:textColor="#fff" 
       android:textSize="50dp" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <ImageView 
       android:id="@+id/buttonShareFavoriteRecipe" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:src="@drawable/ic_launcher" > 
      </ImageView> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:gravity="center" 
       android:text="0296" 
       android:textColor="#fff" 
       android:textSize="50dp" /> 
     </LinearLayout> 
    </TableRow> 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <ImageView 
       android:id="@+id/buttonWeddingDayCheatSheet" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:src="@drawable/ic_launcher" > 
      </ImageView> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:gravity="center" 
       android:text="Most sent" 
       android:textColor="#fff" 
       android:textSize="15dp" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <ImageView 
       android:id="@+id/buttonShareFavoriteRecipe" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:src="@drawable/ic_launcher" > 
      </ImageView> 
     </LinearLayout> 
    </TableRow> 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <ImageView 
       android:id="@+id/buttonWeddingDayCheatSheet" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:src="@drawable/ic_launcher" > 
      </ImageView> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <ImageView 
       android:id="@+id/buttonShareFavoriteRecipe" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:src="@drawable/ic_launcher" > 
      </ImageView> 
     </LinearLayout> 
    </TableRow> 

</TableLayout> 
+0

关于为什么你会认为你的解决方案能够工作的任何评论/解释,你不应该特别拉伸一列。 (这对那些不想通过所有代码的人来说会很好) – njzk2