我已經使用android developer studio創建了以下初始屏幕布局。我想要將由兩個文本視圖和一個圖像視圖組成的內容居中。以下是XML。以android線性佈局居中內容的最佳方式
<?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:background="@drawable/splash_gradient">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView id="@+id/splashscreen"
android:layout_width="100dp"
android:layout_height="250dp"
android:paddingBottom="100dp"
android:layout_centerInParent="true"
android:gravity="center_vertical|center_horizontal"
android:src="@drawable/splash_logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sample"
android:layout_centerInParent="true"
android:fontFamily="@string/font_family_thin"
android:paddingTop="90dp"
android:paddingRight="90dp"
android:textSize="35dp"
android:textColor="#fff"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="App"
android:layout_centerInParent="true"
android:fontFamily="@string/font_family_regular"
android:textSize="35dp"
android:paddingTop="90dp"
android:paddingLeft="100dp"
android:textColor="#fff"
/>
</RelativeLayout>
這看起來像下面的圖片。
這是正確的方式居中我的內容或是否有更好的方式來實現我在尋找什麼呢?請指導我。提前致謝。
我改了一下你的答案讓我的精確設計和它看起來完美。你能指示我有關如何使用此android佈局獲得令人驚歎的UI的任何文檔!我搜索了一下,發現只有基本的教程。 –
我不記得任何教程特別。但是搜索特定於每個佈局的Tutorias:FrameLayout,LinearLayout,RelativeLayout和ConstraintLayout。最後一個是擁有更多選項但也是最複雜的那一個,所以我會先消化熟悉之前的那些。 – Juan
噢,好的。非常感謝你! :) –