2011-04-22 7 views
0

나는 하나의 상대 레이아웃을 추가 한 xml 파일 하나가 있으며 아래에는 두 개의 버튼이 있습니다. 하나는 Signin이고 다른 하나는 newuser이고 signin 버튼은 약간의 문제를 보여줍니다.안드로이드 레이아웃 로그인 버튼

newuser 버튼의 왼쪽에 signin 버튼을 설정했으나 애플리케이션을 실행하는 동안 layout_marginTop = -42로 시도해 보았습니다. 그대로, 나는 newuser 버튼 왼쪽에 머 무르지 않는다는 것을 의미한다. 두 개의 버튼은 가운데와 아래 사이에 있어야한다.

제발 도와 줘서 고마워!


+0

전체 코드를 게시 할 수 있습니까? –

답변

0

<LinearLayout android:id="@+id/ll_three" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_below="@+id/ll_two" android:gravity="center"> 
    <Button 
     android:text="Sign In" 
     android:id="@+id/Button01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
    <Button 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:id="@+id/Button02" 
     android:text="New user"/> 
</LinearLayout> 

을 편집

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout android:id="@+id/RelativeLayout01" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<LinearLayout android:id="@+id/ll_one" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> 
    <TextView android:id="@+id/TextView01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="User Name:"/> 
    <EditText android:id="@+id/EditText01" 
    android:layout_width="200px" 
    android:layout_height="wrap_content"/> 
</LinearLayout> 
<LinearLayout android:id="@+id/ll_two" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_below="@+id/ll_one"> 
    <TextView android:id="@+id/TextView02" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Password:"/> 
    <EditText android:id="@+id/EditText02" 
    android:layout_width="200px" 
    android:layout_height="wrap_content" 
    android:password="true" 
    android:inputType="textPassword"/> 
</LinearLayout> 
<LinearLayout android:id="@+id/ll_three" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_alignParentBottom="true"> 
    <Button 
     android:layout_height="wrap_content" 
     android:text="Sign In" 
     android:id="@+id/Button01" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"/> 
    <Button 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:id="@+id/Button02" 
     android:text="New user" 
     android:layout_weight="1"/> 
</LinearLayout> 
</RelativeLayout> 

이 당신이 찾고있는 시도 : 다음

샘플입니다?

1

당신은 수평의 LinearLayout에 두 개의 버튼을 넣어 자신의 layout_weight를 모두 한 설정 저장 1에 설정할 수 있습니다 LinearLayout에있는 View에 동일한 가중치를 지정하면 그에 따라 공간의 50 %가 사용됩니다. 그런 다음이 "버튼 패널"을 전체적으로 사용할 수 있습니다.

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

    .................... 

    <LinearLayout 
     android:layout_alignParentBottom="true"    
     android:layout_gravity="center_horizontal" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:orientation="horizontal"> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1"/> 
    </LinearLayout> 
</RelativeLayout> 
+0

이 "단추 패널"의 정렬과 너비를 조정하면됩니다. – shihpeng