这是我的代码,我无法将文本视图完全保留在屏幕中心
<?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>
当前输出
答案 0 :(得分: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>