我正在尝试将文本居中在我的TextView
andButton
中。我目前有以下代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#000000" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:gravity="center"
android:text="@string/CouponFinder"
android:textSize="30sp"
android:textColor="#FF0000"
android:typeface="monospace" />
<ImageView
android:id="@+id/couponImage"
android:layout_width="match_parent"
android:layout_weight="0.7"
android:layout_height="0dp"
android:src="@drawable/coupon" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:text="@string/continueButton"
android:textSize="30sp"
android:gravity="center"/>
</LinearLayout>
</RelativeLayout>
但是,Button
andTextView
中的文本在右侧,因此某些文本不在屏幕上......我也收到以下警告LinearLayout
:
This LinearLayout layout or its RelativeLayout parent is possibly useless
任何帮助将不胜感激!!