Questions tagged [layout-gravity]

Android layout parameter that sets the gravity (alignment) of a View or Layout inside its parent container.

Standard gravity constant that a child supplies to its parent. Defines how the child view should be positioned, on both the X and Y axes, within its enclosing layout.

Must be one or more (separated by |) of the allowed constant values.

145 questions
113
votes
5 answers

Android - Center TextView Horizontally in LinearLayout

I have the following basic layout
Jake Wilson
  • 78,902
  • 83
  • 230
  • 344
72
votes
2 answers

Vertical content align in Android EditText

I have a multi-line EditText:
68
votes
4 answers

Text/Layout Alignment in Android (textAlignment, gravity)

What's the difference between android:textAlignment and android:gravity?
Chrizzor
  • 1,063
  • 2
  • 11
  • 18
55
votes
5 answers

How to right-align text in an Android TextView or EditText?

I have an EditText in my application. I want to align the text in it to the right instead of the default left. I tried adding android:layout_gravity="right" but this doesn't seem to work. any other suggestions please?
sherry
  • 1,809
  • 7
  • 21
  • 23
25
votes
9 answers

Center content in scroll view

I want to center my LinearLayout within ScrollView. When LinearLayout's height is small it's centered alright (see image #1) but when LinearLayout's height is bigger than the screen's height then it behaves strange. I cannot see the top of…
Egis
  • 4,048
  • 4
  • 34
  • 50
19
votes
2 answers

layout_gravity in LinearLayout

This is my layout:
DixieFlatline
  • 7,537
  • 23
  • 92
  • 145
16
votes
3 answers

What is exact difference between gravity and layout_gravity

Possible Duplicate: Android - gravity and layout_gravity I have been working on android xml's. I have used android:layout_gravity="center" to align components in specific position. Now a days, when I was working on a Dialog like Activity, I came…
Sahil Mahajan Mj
  • 12,525
  • 8
  • 53
  • 98
14
votes
3 answers

Android - Set Layout_Gravity programmatically for LinearLayout

I've got the following problem: I implemented a HorizontalScrollView which contains in one case a LinearLayout and an ImageView. In this case the image is about 50% of the screen width. So I want to center it. Unfortunately the only way I found to…
Ron
  • 18,164
  • 27
  • 98
  • 185
12
votes
5 answers

Textview Gravity not working properly in android

What's wrong with my code, I'm trying to display my TextView named "invalid", in different locations (left,right,center), but the gravity (left,right,center) won't work! My text.xml is
Krish
  • 304
  • 3
  • 5
  • 18
10
votes
2 answers

FloatingActionButton, layout_anchor and layout_gravity

A bit of a newbie here. I'm about two months into Android development, but I have years of development experience in other environments. Okay. I have a FloatingActionButton which was not showing up where I expected it or wanted it. It's inside a…
10
votes
5 answers

layout_gravity not working

Why my TextView doesn't go right? Update: Well, now I don't just need to set TextView to the right. Now it is very interesting why layout_gravity doesn't work as expected, namely - set the View to the position inside it parent container.
Eugene
  • 55,777
  • 85
  • 212
  • 324
7
votes
3 answers

Programmatically set ImageButton layout_gravity

What I Tried To Do I tried to set my ImageButton's layout_gravity via Java code, the way I want the ImageButton to be is presented like the way within the Orange frame in the image below: The Blue frame is a vertical LinearLayout act as a "base"…
dumbfingers
  • 6,429
  • 5
  • 44
  • 70
6
votes
8 answers

LinearLayout put child at the right side

I m trying to have a textview and a button in linear layout with horizontal orientation. The textview should appear at the starting and the button should appear at the end. I thought giving gravity right to the button would do the trick but the…
5
votes
10 answers

How to align radio button to center

I want radio buttons in the image below to be center aligned. I have used gravity but it's not working. I have used this code
Ragini
  • 222
  • 3
  • 14
5
votes
2 answers

How to set both gravity and layout gravity of a LinearLayout programatically

I am risking writing a duplicate question, but as I was researching the answer to another SO question, I realized that I couldn't find a simple question and answer that included setting both gravity and layout_gravity of a LinearLayout. Also, I was…
Suragch
  • 364,799
  • 232
  • 1,155
  • 1,198
1
2 3
9 10