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.

146 questions
1
vote
0 answers

Android ListActivity doesn't center the items

I have a ListActivity which displays an image and some text. The imageView has a fixed size and I want to center the list horizontally. After endless tries, I set any gravity to center_horinzontal, but nothing works. The list is shown over the whole…
1
vote
4 answers

how to gravity to right in NavigationView

I need to put a menu item at right of text how to change menu item gravity to right in NavigationView ?
hassan
  • 29
  • 1
  • 6
1
vote
1 answer

Android: Inflate a Movable button at center of a RelativeLayout

I would like to inflate a moveable button in the center of a relativelayout (Container), such that when touching it, it can be moved within Container, i.e. the screen. Code is as follows: public void inflate_floating_btn(int k) { …
pearmak
  • 4,979
  • 15
  • 64
  • 122
1
vote
1 answer

Android LinearLayout does not left align contents

I want to create a horizontal line of small images thumbnails on top of the display. They should be lined up from left to write (all floated left). When you click on a thumbnail, its bigger version should be displayed below this line. I decided to…
1
vote
1 answer

center children in a custom RelativeLayout

I have defined a custom relative layout to force a square view in my layout. But I am having trouble centering the children in that relative layout. My custom RelativeLayout is defined as follows: public class SquareView extends RelativeLayout { …
1
vote
3 answers

How to set gravity for the overlayed layer when two layers are overlayed?

LayoutInflater mInflater = LayoutInflater.from(getApplicationContext()); View overView = mInflater.inflate(R.layout.settings, null); addContentView(overView,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); Above shown is…
SMK
  • 324
  • 3
  • 14
1
vote
2 answers

XML Android layout problems

So I am having problems with some XML layout coding... I am supposed to replicate this image but so far I seem to be only able to get this far and the checkout button refuses to stay to the right even when I do use android:gravity="right" to float…
1
vote
3 answers

How to set Layout Gravity to center|right programatically?

I can set the gravity of my element as center|right or center|left in xml like : android:layout_gravity="center|left" but how can i do that programatically?
MRefaat
  • 515
  • 2
  • 8
  • 22
1
vote
2 answers

change text gravity to top in Android

I need to dynamically change Android text Gravity to the TOP in My ListItems. Code used for ListItem: XML layout file:
Abbath
  • 1,002
  • 13
  • 30
1
vote
3 answers

Android button to appear on video view

How can i get the button to be on top of the video view instead of above it? Here's the code:
Tom Doe
  • 331
  • 6
  • 23
1
vote
1 answer

How to align elements inside a form

Calling out to css masters at SO! I have a form that's created with gravity forms. The logical order of all input fields in the code is 1) Radiobuttons 2) All string/text inputs 3) textarea I'm trying to make it so that a tab from radiobuttons…
Alisso
  • 1,861
  • 1
  • 17
  • 32
1
vote
0 answers

how to align text to top of a text view dynamically

I have hit a problem when trying to align my text to the top of a text view dynamically. I have a method that creates textviews dynamically. I have set the gravity of the text view to Gravity.TOP. Which a believe should place the text at the very…
Paul Ledger
  • 1,125
  • 4
  • 21
  • 46
1
vote
1 answer

LinearLayout set gravity

I have frame layout and inside of it linear layout with four buttons. When i write in xml works great but i want to write in java code. THIS WORKS
rikkima
  • 95
  • 1
  • 11
1
vote
3 answers

How to set ImageView in the center of layout from code?

I try next LinearLayout.LayoutParams b = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); b.gravity =Gravity.CENTER; ivOne.setLayoutParams(b); But this…
Kostya Khuta
  • 1,846
  • 6
  • 26
  • 48
1
vote
1 answer

How to set button layout_gravity="fill_vertical" programmatically?

I got a GridLayout, and two or more button inside, and all the buttons must with same width. My problem is that when the buttons having different line number of text, the marginTop of button will different too. How can I fix this? I want all the…