2017-07-31 5 views
0

を揃え、私が持っているコードですが、私は正確に画面の中央にテキストビューの両方を維持することができません中央2つのテキストビューは水平にここ

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@mipmap/home_background" 
     android:gravity="center_vertical" 
     tools:context="com.couchbunny.www.MainActivity"> 

     <ImageView 
      android:id = "@+id/icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@mipmap/icon" 
      android:layout_centerHorizontal = "true" 
      android:layout_centerVertical = "true"/> 
     <TextView 
      android:id="@+id/couch" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="36sp" 
      android:lineSpacingExtra="19sp" 
      android:layout_below = "@id/icon" 
      android:layout_marginTop="10dp" 
      android:text="couch" 
      android:gravity="center_vertical|right" 
      android:textColor="#ffffff" 
      /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="36sp" 
      android:lineSpacingExtra="19sp" 
      android:layout_below = "@id/icon" 
      android:layout_toRightOf="@id/couch" 
      android:layout_marginTop="10dp" 
      android:text="bunny" 
      android:gravity="center_vertical" 
      android:textColor="#f7ca18" 
      /> 

    </RelativeLayout> 

電流出力

enter image description here

所望の出力 enter image description here

答えて

0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@mipmap/home_background" 
android:gravity="center_vertical" 
tools:context="com.couchbunny.www.MainActivity"> 

<ImageView 
    android:id = "@+id/icon" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@mipmap/icon" 
    android:layout_centerHorizontal = "true" 
    android:layout_centerVertical = "true"/> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_below = "@id/icon" 
    android:gravity="center"> 

    <TextView 
     android:id="@+id/couch" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="36sp" 
     android:lineSpacingExtra="19sp" 
     android:layout_marginTop="10dp" 
     android:text="couch" 
     android:gravity="center_vertical" 
     android:textColor="#ffffff" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="36sp" 
     android:lineSpacingExtra="19sp" 
     android:layout_below = "@id/icon" 
     android:layout_toRightOf="@id/couch" 
     android:layout_marginTop="10dp" 
     android:text="bunny" 
     android:gravity="center_vertical" 
     android:textColor="#f7ca18" 
     /> 

</LinearLayout> 


</RelativeLayout> 
+0

それは私のために働いた、あなたのコードを私に説明することができれば、それは私のために役立つだろう。 – gates

+0

レイアウトの重心を与える必要がある場合は – MinnuKaAnae

+0

plsが受け入れます – MinnuKaAnae

関連する問題