我有一个TextView活动.我想将它对齐在屏幕的底部,在中心,我希望TextView适合屏幕的宽度. 这是我的XML: RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.andro
这是我的XML:
<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"
android:background="#ffffff"
tools:context=".ShowCard" >
<TextView
android:id="@+id/textView"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#33000000"
android:textColor="#000000"
android:text="@string/lorem_ipsum" />
结果不是我所期望的. TextView的宽度不是全屏,但是左右两边留有一小块空闲空间(如填充/边框,但我没有设置填充/边框!).
你知道为什么吗?建议?
试试这个<?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/textView"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#33000000"
android:textColor="#000000"
android:text="@string/lorem_ipsum" />
</RelativeLayout>
