2014-03-02 3 views
2

내 XML 레이아웃에 문제가 있습니다. xml을 사용하여 "simplemessage"가 상단에 붙고 "textchange"가 화면 중앙에 채워지고 가운데에 배치되는 동안 "hiraganaconfbutton"이 아래쪽에 붙어있는 것을 사용하여 레이아웃을 만들고 싶습니다. 중력을 시도했지만 중심에 두었습니다. 어떤 이유로이 LinearLayout 중력

당신의 도움이

이 내 XML 레이아웃

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center_horizontal" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/simplemessage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/guess" 
     android:textSize="19sp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_horizontal" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/textchange" 
      android:layout_width="wrap_content" 
      android:layout_height="392dp" 
      android:text="@string/a" 
      android:textSize="60sp" /> 

    </LinearLayout> 

    <Button 
     android:id="@+id/hiraganaconfbutton" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/confirm" /> 

</LinearLayout> 
+0

이 상대 레이아웃에있을 수 있습니까? – deadfish

답변

3

는 그렇게 할 수 있습니다 미리 감사드립니다 작동하지 않습니다? 아래

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="center_horizontal" 
       android:orientation="vertical" > 

    <TextView 
      android:id="@+id/simplemessage" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/guess" 
      android:gravity="center" 
      android:textSize="19sp" 
      android:layout_alignParentTop="true"/> 

    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/simplemessage" 
      android:layout_above="@+id/hiraganaconfbutton" 
      android:orientation="horizontal" > 

     <TextView 
       android:id="@+id/textchange" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="center" 
       android:text="@string/a" 
       android:textSize="60sp" /> 

    </LinearLayout> 

    <Button 
      android:id="@+id/hiraganaconfbutton" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:gravity="center" 
      android:text="@string/confirm" /> 

</RelativeLayout> 

preview

+0

감사합니다. 괜찮습니다. – Taziz

0

사용 상대 레이아웃 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"    
       > 

    <TextView 
      android:id="@+id/simplemessage" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/guess" 
      android:gravity="center" 
      android:textSize="19sp" 
      android:layout_alignParentTop="true"/> 

    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/simplemessage" 
      android:layout_above="@+id/hiraganaconfbutton" 
      android:orientation="horizontal" > 

     <TextView 
       android:id="@+id/textchange" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="center" 
       android:text="@string/a" 
       android:textSize="40sp" /> 

    </LinearLayout> 

    <Button 
      android:id="@+id/hiraganaconfbutton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:gravity="center" 
      android:text="@string/confirm" /> 

</RelativeLayout>