可以用相对布局RelativeLayout,给RelativeLayout一个id,
然后按钮按RelativeLayout作为父控件进行相对布局,从而置于最上层。
代码部分:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=" http://schemas.android.com/apk/res/android "
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webMainLayout"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnRegister"
android:layout_alignBottom="@id/webMainLayout"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="我是最上层按钮"
/>
</RelativeLayout>
注:此按钮会在最上层的右下位置 因为
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
想更改成其它位置,改变令你想处的位置基于父控件,如左上:
android:layout_alignParentLeft="true"
然后按钮按RelativeLayout作为父控件进行相对布局,从而置于最上层。
代码部分:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=" http://schemas.android.com/apk/res/android "
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webMainLayout"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnRegister"
android:layout_alignBottom="@id/webMainLayout"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="我是最上层按钮"
/>
</RelativeLayout>
注:此按钮会在最上层的右下位置 因为
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
想更改成其它位置,改变令你想处的位置基于父控件,如左上:
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
可以用相对布局RelativeLayout;然后给他一个id;然后再写那个按钮时把他相对的父控件式这个相对布局的id;下面是按钮总在最上层的右下角:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
RelativeLayout
xmlns:android
=
"http://schemas.android.com/apk/res/android"
android:layout_width
=
"fill_parent"
android:layout_height
=
"fill_parent"
android:id
=
"@+id/webMainLayout"
>
<
Button
android:layout_width
=
"wrap_content"
android:layout_height
=
"wrap_content"
android:id
=
"@+id/btnRegister"
android:layout_alignBottom
=
"@id/webMainLayout"
android:layout_alignParentRight
=
"true"
android:layout_alignParentBottom
=
"true"
android:text
=
"切换邮箱"
/>
</
RelativeLayout
>
|