简体   繁体   中英

How do I get a TextView to the center of the bottom?

You can get the TextView to Bottom, Center, Center Horizontal and others, but so far I didn't find out how to get it to the center of the bottom if it is even possible.

This is the code for my button:

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="99dp"
    android:layout_gravity="bottom"
    android:background="@drawable/sq_donate" />

Is it possible to do it?

EDIT, whole layout here:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.tominocz.stonequestapp.MainActivity"
    tools:ignore="MergeRootFrame,ContentDescription,HardcodedText,SpUsage,TextViewEdits,Deprecated,SmallSp" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:src="@drawable/sq_bg" />

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="99dp"
        android:layout_gravity="bottom"
        android:background="@drawable/sq_donate" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="283dp"
        android:layout_height="236dp"
        android:layout_gravity="center_horizontal"
        android:editable="true"
        android:gravity="center"
        android:text="sdf"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="15sp"
        android:textStyle="bold|normal"
        android:typeface="sans" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="263dp"
        android:layout_height="238dp"
        android:layout_gravity="center_horizontal"
        android:src="@drawable/sq_logo" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="300dp"
        android:layout_height="171dp"
        android:layout_gravity="center_horizontal"
        android:editable="true"
        android:gravity="center"
        android:text="s"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#528A50"
        android:textSize="17sp"
        android:textStyle="bold|normal"
        android:typeface="sans" />

</FrameLayout>

您只需要添加另一个参数

android:layout_gravity="bottom|center_horizontal"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM