Android 文本视图不适合屏幕

Android 文本视图不适合屏幕,android,textview,Android,Textview,我有一个带有文本视图的活动。我想把它在屏幕的底部,中间对齐,我希望文本视图适合屏幕的宽度 这是我的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="

我有一个带有文本视图的活动。我想把它在屏幕的底部,中间对齐,我希望文本视图适合屏幕的宽度

这是我的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" />

结果并不是我所期望的那样。文本视图的宽度不是全屏的,但在左右两侧都留有一小部分可用空间(比如padding/border,但我没有设置padding/border!)

你知道为什么吗?建议?

试试这个

<?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>



使用“填充父对象”属性,它应该填充整个屏幕的宽度。

对不起,我是个愚蠢的家伙! 我没有看到容器XML代码中包含四个填充行:

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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
从父相对布局。


<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: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" />

使用此

请使用根视图添加xml代码包含的布局中是否有填充或边距?显示完整的XML。@massimostanzoWelcome@Ndupza“fill\u parent”属性已弃用。建议使用“匹配父项”。
<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: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" />