Reputation: 22486
Android Studio 0.3.7
Hello,
I have the following TextView
that is on a Linearlayout (vertical)
.
I want to display the TextView
just about 5dp
from the bottom of the layout. However, I can't seem to do that.
I have played around with the different properties of the android:layout_marginBottom
and some other properties as well.
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Sign Up with StarBucks"
android:id="@+id/tv_signup"
android:clickable="true"
android:textColor="#380aff"
android:enabled="true"
android:textStyle="bold|italic"
android:gravity="center_horizontal"
android:layout_marginBottom="5dp"/>
Can anyone tell me what is the correct property to set to get the Textview
positioned from the bottom of the layout.
Many thanks for any suggestions,
Upvotes: 0
Views: 118
Reputation: 1754
Try setting android:layout_gravity="bottom"
or else if you want your textview to be horizontally center then you may set
android:layout_gravity="bottom|center_horizontal"
Upvotes: 1
Reputation: 2616
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center" >
//other controls define here
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
Use this
Upvotes: 2
Reputation: 11131
try this...
<TextView
android:padding_bottom="5dp"
android:gravity="bottom|center_horizontal"
........ />
Upvotes: 1
Reputation: 2616
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
Upvotes: 2
Reputation: 2776
The textView have to be child of the RelativeLayout then You can use alignParentBottom="true"
and set marignBottom
Upvotes: 1