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
2
votes
7 answers

How to keep a TextView center aligned within a RelativeLayout with mutliple TextViews

I have this RelativeLayout with two TextViews, One with center aligned and the other end aligned,
2
votes
0 answers

How do I create a square grid using a ConstraintLayout with labels for the rows that are vertically centered?

I need to create a square grid with labels for the rows on the left side. The grid should use the entire space available on the device while keeping width=height. Because this grid has several rows and several columns automatically adjusted, I…
2
votes
1 answer

Android wrap_content too wide when centred text of TextView is long

You can use either layout_gravity or gravity for text centring. With layout_gravity:
digory doo
  • 1,978
  • 2
  • 23
  • 37
2
votes
0 answers

Can layout_gravity override parent gravity?

Does the gravity setting set by the parent override all layout_gravity settings set by its children? It seems to when I try it. Is there a way to bypass this behaviour? I would like to use a LinearLayout with a global gravity, but I want one element…
Vas
  • 2,014
  • 3
  • 22
  • 38
2
votes
4 answers

android:layout_gravity="center" can't set the button in the center of titlebar?

I am really a new fresher in android, I know android:layout_gravity sets the gravity of the View or Layout in its parent.And android:gravity sets the gravity of the content of the View its used on.Refer But when I set the titlebar Linearlayout…
Gaby
  • 130
  • 1
  • 8
2
votes
1 answer

Aligning LinearLayout to the bottom of a DrawerLayout

I've implemented a DrawerLayout in my application's primary XML layout - and I've created a footer (basically a horizontal [navigation-ish] bar) which fill the bottom of the screen. The problem is - it is continually appearing at the top of the…
2
votes
5 answers

Android: gravity ImageView in RelativeLayout failed

I would like to align this ImageView in center (horizontal and vertical):
anthony
  • 7,653
  • 8
  • 49
  • 101
2
votes
3 answers

Unable to use layout_gravity for ListView inside DrawerLayout

I am trying to add a Navigation Drawer inside my app. Here's the code:
2
votes
2 answers

How to solve error with ScrollView containing a child with layout_gravity="center"

I need a ScrollView which displays content in it's center if the screen is Big Enough, else it should display scroll. Here is the example code that i used for testing
Ashok Varma
  • 3,489
  • 3
  • 28
  • 43
2
votes
1 answer

How to align items at the top of a GridView in Android?

I try to make my own gallery application. The problem is that my image views appear in the bottom of the gridview that contains them. How to align them at the top? I've tried to set the gravity but it's not working.
mawus
  • 1,178
  • 1
  • 11
  • 25
2
votes
3 answers

android Layout_gravity (not gravity) and Layout_marginTop(not marginTop) programmatically

I need to programmatically create a Toast that use an ImageView and a TextView, and that appears in the middle of the screen, and I have done it. THIS IS THE RENDER I WANT (The black square with the heart is the ImageView image, and the "J'aime"…
Laurent Russier
  • 658
  • 5
  • 24
2
votes
2 answers

android:gravity does not align as it should

I have some code that should center a text in button, but the text is not aligned exactly in the middle. It is located a little at the bottom. How I could fix this?