我想创建一个顶部有独立块的布局,这是我到目前为止的方式,我无法摆脱边缘并使块居中
我无法弄清楚如何让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>
答案 0 :(得分: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>