4

I have Textview inside Linearlayout. I want it to be displayed at bottom but it is showing me only at the centre. My xml file is look like the code below. I tried replacing LinearLayout with RelativeLayout but it did't worked.

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/black">
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000"
android:layout_gravity="bottom" >

 </RelativeLayout>

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/TextViewBottomTitle"
    android:text="@string/app_logo_bottom"
    android:textColor="@color/logo_color"
    android:gravity="center"
    android:textSize="@dimen/logo_size"></TextView>
<TextView
    android:id="@+id/TextViewBottomVersion"
    android:text="@string/app_version_info"
    android:textSize="@dimen/version_size"
    android:textColor="@color/version_color"
    android:background="@color/version_bkgrd"
    android:layout_height="fill_parent"
    android:lineSpacingExtra="@dimen/version_spacing"
    android:layout_width="fill_parent"
    android:layout_gravity="center_vertical|center_horizontal"
    android:gravity="center"></TextView>


</LinearLayout>

Any one have idea?

4

4 回答 4

6

这可以帮助您:

  <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:background="@android:color/black">

<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000"
android:layout_gravity="bottom" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/TextViewBottomTitle"
    android:text="@string/app_logo_bottom"
    android:textColor="@color/logo_color"
    android:gravity="bottom"
    android:layout_alignParentBottom="true"
    android:textSize="@dimen/logo_size"></TextView>
<TextView
    android:id="@+id/TextViewBottomVersion"
    android:text="@string/app_version_info"
    android:textSize="@dimen/version_size"
    android:textColor="@color/version_color"
    android:background="@color/version_bkgrd"
    android:layout_height="fill_parent"
    android:lineSpacingExtra="@dimen/version_spacing"
    android:layout_width="fill_parent"
    android:layout_gravity="bottom"
    android:layout_alignParentBottom="true"
    android:gravity="bottom"></TextView>

 </RelativeLayout>




</LinearLayout>
于 2013-07-26T04:19:00.960 回答
1

可以试试这对我有用:

android:layout_gravity="bottom"
于 2017-09-01T04:54:52.793 回答
0

尝试添加:

android:gravity="bottom|center"
于 2020-03-14T15:09:45.287 回答
0

尝试这个

android:scaleType="fitEnd"
于 2019-06-17T14:10:43.900 回答