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

How to change layout_gravity in ConstraintLayout programmatically?

I got an XML file that includes a ConstraintLayout and inside this layout i got three views. The layout as its width set to "wrap_content" which automatically wrap it to the left side like this: in the XML edit window, when i set layout_gravity to…
0
votes
1 answer

How to center a middle child in a layout and set it siblings packed closed to it?

I have an horizontal linear layout with 3 child views. I want to center the middle child horizontally and make its siblings 8dps to its sides. Is this the clean way to do so?
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
0
votes
0 answers

Why do START and TOP work unexpectedly for gravity of Relative Layout

I have done some experiments with Relative Layout gravity in Android Studio. I am very perplexed with results gotten. Let's look at my xml.
0
votes
1 answer

What to do when Layout Gravity not available/being suggested under any type of view

When I tried to add - android:layout_gravity inside android.support.design.widget.NavigationView There is neither any option inside the design mode & when I tried to write the code it was displaying incorrect After researching I found that Android…
0
votes
1 answer

Place on the right in LinearLayout

i have to place the seconds TextView and ImageView on the right, but gravity doesn't move. How can I do? Maybe 'gravity' isn't appropriate? Thanks!
0
votes
1 answer

Progressbar not showing inside toolbar

I want to show progressbar that contain inside toolbar. But it's not visible when I added layout_gravity="bottom", I want progressbar bottom of toolbar, just like browsers. Is there any way to achieve this? What about Appbarlayout??
0
votes
1 answer

set TextView's gravity programmatically in constraint layout

I am programmatically change the Gravity and background of TextView in ConstrainLayout the background color change correctly but the gravity don't change how to solve this problem please if(currentUserId.equals(model.getUserId())){ …
0
votes
0 answers

How layout_gravity is possible to use in relativeLayout?

There is no layout_gravity attribute in RelativeLayout class and RelativeLayout.LayoutParams inner class. It only has android:gravity attribute. But still I am able to add layout_gravity attribute to RelativeLayout in xml file and make the layout…
0
votes
1 answer

how to dynamically modify the recycler view's layout?

I write a chat application using Firebase. In ChatActivity, there are a recycler view to display chatting information. The following image is the first loading is correct. When enter the message send to others, the layout of some messages become…
0
votes
1 answer

Button top increase with multiple lines

Some very very strange behaviour was appearing in my Android application. I was extending Button to replace the standard. In my own button I set: - TextAppearence (text 16px, bold..) - BackgroundDrawable (to an selector that replaced the standard…
neteinstein
  • 17,529
  • 11
  • 93
  • 123
0
votes
1 answer

how to set inflate layout center which added dynamically in linear layout Android

I am adding inflate layout dynamically in linear layout,i need to set layout center based on number of layouts.suppose if layouts are two , then it start showing from center. following is my xml:
0
votes
2 answers

Center gravity property for text doesn't work in android button

I have two button in my layout inside my TableLayout, but the text is not in center, I try to use android:gravity="center" and android android:layout_gravity="center", but seems it doesn't work. How can i fix this? thanks in…
Denny Kurniawan
  • 1,581
  • 2
  • 15
  • 28
0
votes
1 answer

Android Floating Action Button wrong position despite gravity is set

I'm currently facing two different issues, both regarding fab gravity behavior. In my layout I have a section consisting in a FrameLayout with an ImageView and a FloatingActionButton as children views. ` *Here's a toolbar* …
0
votes
1 answer

android xml put component on top with layout_gravity="center"

I'm trying to put admob ad at the top of my app but the normal text needs to stay centered in the middle... with the below code only one of the components are displayed..
martinyyyy
  • 1,652
  • 3
  • 21
  • 44