2011-01-24 35 views
1

Hy!在视图的按钮处绘制按钮

我想在按钮上有一个按钮,并在一个线性布局的视图中居中。

非工作例如:

<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:id="@+id/login_btnew" android:text="Make a new Account"></Button> 

解决方案?

感谢

回答

2

你可能想尝试以下RelativeLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent"> 


<Button android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:id="@+id/login_btnew" 
    android:text="Make a new Account"></Button> 

</RelativeLayout> 
0

我这样做,例如以下列方式:

我中有你在上面提到的线性布局我已经滚动视图,并在底部我有个按钮。对于滚动视图使用android:layout_weight =“1000”,对于按钮使用android:layout_weight =“1”可得到所需的结果。使用android中心按钮:layout_gravity =“center_horizo​​ntal”

希望有所帮助。

0

使用此

<Button android:id="@+id/login_btnew" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" android:text="Make a new Account" 
android:layout_gravity="bottom"/> 
0

您有layout_weight工作,并把在另一个LinearLayout中的布点。

你可以做某事像(伪代码)

<linearlayout layout_height=fill_parent layout_with=fill_parent> 
    #the "top" fields 
    <linearlayout layout_height=fill_parent layout_with=fill_parent layout_weight=1> 
     <elem1/><elem2/><elem3/> 
    </linearlayout> 
    #the bottom field (button) 
    <button layout_height=wrap_content layout_with=wrap_content layout_gravity=center_horizontal gravity=center ></button> 
</linearlayout>