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
1 answer

Android LinearLayout set layout_gravity in java code

I have a problem on this layout :(
e-info128
  • 3,727
  • 10
  • 40
  • 57
2
votes
2 answers
2
votes
5 answers

How to center View inside layout

I have to build layout like at the picture below. The main task is to center the text. I use this xml for implementing layout.
dimetil
  • 3,851
  • 2
  • 29
  • 47
2
votes
2 answers

How to make android:layout_gravity="bottom|center_horizontal" stays at bottom

I have a vertical LinearLayout which has a list view and one ImageView at the bottom and one at top and the list view filled up the space left behind. It looks like this:
michael
  • 106,540
  • 116
  • 246
  • 346
1
vote
0 answers

layout_gravity or layout_margin at the sony ericsson xperia?

My problem is to show a box with a textView (for example) with specified layout_gravity or layout_margin at the sony ericsson xperia. For other devices the following code do what it should do but not for the xperia. Using it at xperia the box is…
AnWi
  • 69
  • 1
  • 8
1
vote
3 answers

LayoutGravity of View inside Toolbar is not working properly

I am using CollapsinToolbarLayout and I have included toolbar a TextView inside my Toolbar and want to make it centered.
1
vote
1 answer

how to center a view in a constraint layout 1.0

I have a view (FrameLayout) in a constraintLayout For tablet devices (only) I want to have this configuration 1) its max height to say 100dp 2) It has to be wrap content 3) It has to be centered in its parent (vertically and horizontally). I'm…
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
1
vote
1 answer

how to set BottomNavigationView items in the center in android (Kotlin)

I have 3 items in my BottomNavigationView that I resized every Item with this code : val menuView = bottomNavigation.getChildAt(0) as BottomNavigationMenuView for (i in 0 until menuView.childCount) { val iconView =…
1
vote
2 answers

Android layout_gravity Bottom/Top in LinearLayout

There are millions of questions and answers in related to "layout_gravity Bottom/Top in LinearLayout" on stack overflow but I still haven't solved my problem. I want to place my EditText which says "Please place me at the very top" at the very top,…
Gurcan
  • 428
  • 1
  • 8
  • 19
1
vote
3 answers

How to set layout_gravity to a cardview in android dynamically

I am trying to create a chatting like functionality in my app and for the chat text i am using a cardview. I want the cardview to be aligned to the right side of the screen for sent messages. But when i set gravity attribute to the parent of the…
Ashu
  • 2,970
  • 1
  • 19
  • 31
1
vote
4 answers

Android layout_gravity for TextView in Java

I want to change the layout gravity for a TextView. Via XML, you'd do that via android:layout_gravity="value". I know that in order to change the gravity itself, via XML you'd do android:gravity="value", and in Java you'd do…
avi12
  • 37
  • 1
  • 8
1
vote
1 answer

Use of setGravity() in GridView

I can't understand the use of android:gravity and setGravity() of GridView. android:gravity Specifies the gravity within each cell. center_horizontal - Place object in the horizontal center of its container, not changing its size. setGravity(int…
1
vote
2 answers

Scollview doesn't scroll a Linearlayout with layout_gravity="bottom"

I've got a Scrollview and a LinearLayout as its child. I set the Linearlayout's layout_gravity to "bottom", because I want to add some custom views programatically to the Linerarlayout, which are dragged down to the bottom by the layoutgravity…
1
vote
1 answer

How to force FAB go to the bottom of the layout?

My first time using FAB. NO matter what setting I use for gravity and anchor attributes, the FAB always appears on top. I want to make it appear at the bottom right corner. How am I supposed to achieve that? My layout xml