2014-10-29 90 views
0

我想創建一個獨立的佈局塊在上面,這是我如何得到它到目前爲止,我無法擺脫邊緣和中心塊 enter image description hereAndroid的表格佈局無邊距

我的無法弄清楚如何讓4個區塊這樣排列,我可以從4個區塊中製作一個單獨的圖像,但我想分別爲每個區塊製作動畫(介紹動畫)。

任何想法?

這是我LoginLayout.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/bg_login" 
    android:paddingBottom="15dp" 
    android:paddingLeft="15dp" 
    android:paddingRight="15dp" 
    android:paddingTop="15dp" 
    tools:context=".MainActivity" > 

    <TableLayout 
     android:layout_width="250dip" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:orientation="vertical" > 

     <TableRow 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:weightSum="3" > 

      <!-- Column 1 --> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="0dip" 
       android:layout_weight="1" /> 

      <!-- Column 2 --> 

      <ImageView 
       android:id="@+id/icon_sound" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/icon_sound" /> 

      <!-- Column 3 --> 

      <ImageView 
       android:id="@+id/icon_video" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/icon_video" /> 
     </TableRow> 

     <TableRow 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:weightSum="3" > 

      <!-- Column 1 --> 

      <ImageView 
       android:id="@+id/icon_sound" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/icon_photo" /> 

      <!-- Column 2 --> 

      <ImageView 
       android:id="@+id/icon_sound" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/icon_draw" /> 

      <!-- Column 3 --> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="0dip" 
       android:layout_weight="1" /> 
     </TableRow> 
    </TableLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="vertical" 
     android:padding="10dp" > 

     <ImageView 
      android:id="@+id/logo_selfierush" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingBottom="25dp" 
      android:src="@drawable/logo" /> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:paddingBottom="15dp" 
      android:text="Connect to get started" 
      android:textColor="#24b762" /> 

     <Button 
      android:id="@+id/btnEmail" 
      style="@style/DefaultButtonText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="4dp" 
      android:background="@drawable/button_default_bg" 
      android:padding="10dp" 
      android:text="Connect with email" /> 

     <Button 
      android:id="@+id/btnFb" 
      style="@style/ButtonText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="4dp" 
      android:background="@drawable/layers_fb_button_bg" 
      android:paddingBottom="10dp" 
      android:paddingLeft="30dp" 
      android:paddingRight="10dp" 
      android:paddingTop="10dp" 
      android:text="Connect with Facebook" /> 

     <Button 
      android:id="@+id/btnGplus" 
      style="@style/ButtonText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="4dp" 
      android:background="@drawable/layers_gplus_button_bg" 
      android:paddingBottom="10dp" 
      android:paddingLeft="30dp" 
      android:paddingRight="10dp" 
      android:paddingTop="10dp" 
      android:text="Connect with Google+" /> 

     <Button 
      android:id="@+id/btnTwitter" 
      style="@style/ButtonText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="4dp" 
      android:background="@drawable/layers_twitter_button_bg" 
      android:paddingBottom="10dp" 
      android:paddingLeft="30dp" 
      android:paddingRight="10dp" 
      android:paddingTop="10dp" 
      android:text="Connect with Twitter" /> 
    </LinearLayout> 

</RelativeLayout> 
+1

是否有使用TableLayout?你可以在沒有一個佈局文件的情況下做到這一點。 – 2014-10-29 20:09:34

回答

1

可以達到同樣的形狀沒有一個TableLayout的複雜性。堅持一個的RelativeLayout和觀點的位置:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    tools:context=".MyActivity"> 

    <View 
     android:id="@+id/yellow" 
     android:layout_width="80dp" 
     android:layout_alignParentBottom="true" 
     android:layout_height="80dp" 
     android:background="#fc0" /> 

    <View 
     android:id="@+id/blue" 
     android:layout_toEndOf="@id/yellow" 
     android:layout_alignParentBottom="true" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:background="#00f" /> 

    <View 
     android:id="@+id/green" 
     android:layout_above="@id/blue" 
     android:layout_toEndOf="@id/yellow" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:background="#0f0" /> 

    <View 
     android:id="@+id/red" 
     android:layout_toEndOf="@id/green" 
     android:layout_above="@id/blue" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:background="#f00" /> 

</RelativeLayout> 

Tetris layout :)

+1

非常感謝!它的工作就像一個魅力 – RonEskinder 2014-10-30 22:32:54