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

Gravity TOP not working when using ScaleType.CENTER_CROP in a ImageView

I have an activity that shows a imageview with a random bitmap from assets folder. I'm loading the image view with this code: ImageView imv = new ImageView(ctx); imv.setAdjustViewBounds(true); …
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
0
votes
5 answers

Linear Layout layout_gravity on View is not working

I am building an application where I need to make some layout. Normally I use Relative Layout and custom views which makes my work however this time, I think of using Liner Layout so I made this below XML. My aim was to make a child linear layout…
Saty
  • 2,563
  • 3
  • 37
  • 88
0
votes
2 answers

Why Views are not aligned right to left?

I have this horizontal Layout in a vertical Layout. Inside my horizontal Layout I have to views (Spinners) which I want to be displayed right to left. The top image is what I'm getting right now. The bottom is what I expect. Very simple. I've been…
Fatima
  • 869
  • 10
  • 35
0
votes
1 answer

What's the difference between gravity="center_vertical" and layout_centerVertical="true"

If I try to center the current view vertically within its parent. Which one should I use? I saw TextViews use gravity="center_vertical" and ImageViews uselayout_centerVertical="true". I am not sure why?
David Liu
  • 16,374
  • 12
  • 37
  • 38
0
votes
1 answer

Widget appears in the left even with attribute android:layout_gravity="center_horizontal"

I am developping an application and currently working on the graphical interface. I would like to have the first imageView in the center of the screen. I used the attribute android:layout_gravity="center_horizontal" but I have the image appears in…
akari
  • 617
  • 1
  • 11
  • 32
0
votes
2 answers

how i set layout_gravity in java file

I want to set layout in Java code file. I use the following code to set this layout to center theme = db.getthemeByID(id); String themePath = theme.getFilepath(); int resid = getResources().getIdentifier(themePath,…
user3001046
  • 235
  • 1
  • 10
  • 28
0
votes
1 answer

android:layout_alignParentBottom="true" and android:gravity="bottom" seem to have no affect on RelativeLayout

I have a viewPager which I'm attempting to set at the bottom of the screen (along with all other items in the last RelativeLayout) however android:layout_alignParentBottom="true" and android:gravity="bottom" seem to have no affect on RelativeLayout…
0
votes
1 answer

What is difference between .setGravity(...) method and getLayoutParams().gravity=x?

If you want to set the gravity of a View like LinearLayout programmatically, you have 2 ways: 1) LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, …
Bob
  • 22,810
  • 38
  • 143
  • 225
0
votes
1 answer

ImageView and TextView of LinearLayout not equal width

I've been stuck on this for quite some time now. The problem is that I have a linearlayout consisting of multiple textViews and an imageView. However, the imageview has a smaller width than the textviews. I tried everything i could find, but I…
user3162649
  • 243
  • 1
  • 2
  • 11
0
votes
1 answer

How do I stack Buttons and TextViews neatly in FrameLayout?

I am trying to program an alternative landscape view file (an xml file) for my app, and I must use FrameLayout instead of LinearLayout (that's what the book said). But Framelayout does not stack well, so we are supposed to use android:layout_gravity…
Azurespot
  • 3,066
  • 3
  • 45
  • 73
0
votes
2 answers

How do I disable gravity for my android app

See I have this android app and I kinda designed it using absolute positioning of elements so when I turn my phone 90 degrees the look is completely messed up. How I do I force my app to not change the layout when I turn my phone !
Aditya
  • 1,240
  • 2
  • 14
  • 38
0
votes
1 answer

Android Gridview - Items align in direction of scroll

This is basically the same question as GridView - sometimes rows are top-aligned, sometimes they're bottom-aligned! but that doesn't seem to provide a sufficient answer, or at least one that works with my problem. I have a gridview with items in it.…
Russ Wheeler
  • 2,590
  • 5
  • 30
  • 57
0
votes
6 answers

how to center a textview in linearlayout

I have the following view in xml. I have a textview at the top which is a banner. I then have a listview which holds messages and another textview which holds the String 'There are no messages'. At runtime i check to see if there are any messages in…
turtleboy
  • 8,210
  • 27
  • 100
  • 199
0
votes
2 answers

How to set gravity position to bottom right of parent?

I am adding button in FrameLayout at run time, that I want to set at bottom|right of parent. LayoutParams lp = new LayoutParams(android.widget.FrameLayout.LayoutParams.WRAP_CONTENT, …
CoDe
  • 11,056
  • 14
  • 90
  • 197
0
votes
0 answers

Child's gravity is ignored

I have custom layout (eventually extends ViewGroup), which contains 2 ImageButtons and 1 custom view (extends SurfaceView). My problem is thatandroid:layout_gravity="center" on my images is not working. Furthermore it is not even show on the…
Oron
  • 121
  • 5
1 2 3
9
10