安卓入门.RelativeLayout相对布局1

RelativeLayout相对布局

所谓相对布局,即第二个控件的摆放,为第一个控件的相对位置


	<TextView 
	    android:id="@+id/textView1"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:background="#FF0000"
	    android:text="第一个"
	    />
	<TextView 
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:background="#00ff00"
	    android:text="第二个"
	    android:layout_toRightOf="@id/textView1"//控件摆放在id为textView1控件的右边
	    />

@id,为引用一个已经创建好的控件id
@+id,为创建一个新的控件id


android:layout_toLeftOf	摆放在左边
android:layout_below	摆放在下边
android:layout_above	摆放在上边


android:layout_alignRight="@id/textView1"对齐到右边


猜你喜欢

转载自8850702.iteye.com/blog/2276061