Questions tagged [android-gravity]
64 questions
2
votes
1 answer
Gravity sensor listener not working
I want to get accelerometer sensor data which is in earth axis through a service. I read about a way to do it as well on one of the posts on stackoverflow. But I have an issue.
@Override
public void onSensorChanged(SensorEvent event) {
…

Shaharyar Babar
- 21
- 3
2
votes
2 answers
What is the priority about gravity and layout_gravity in android?
I am testing LinearLayout and create a LinearLayout with 2 TextViews.
the LinearLayout has the attribute gravity="center_vertical", and the first TextView within the LinearLayout has attribute layout_gravity="top".
gravity="center_vertical" of…

karon
- 21
- 1
2
votes
1 answer
Gravity in LinearLayout - android?
I created bellow Layout :
user4813855
2
votes
3 answers
Align single item to center in RecyclerView android
Suppose I have one OR two items in RecyclerView . How could I display them in center
RecyclerView must have width and height is match_parent
AFAIK recyclerView starts from top. How could I give gravity = center to its single item. I mean if only 1…

Zar E Ahmer
- 33,936
- 20
- 234
- 300
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
1 answer
SupportMapFragment with custom view on top
I'm having some issues with customizing SupportMapFragment layout. I basically want to add an custom view at the bottom of the map fragment layout.
I managed to add an view programmatically to the fragment like this:
@Override
public View…

Ionut Negru
- 6,186
- 4
- 48
- 78
2
votes
4 answers
Android:how to center individual views when layout's gravity is fixed
I am using Linear Layout for this xml file :
user4865748
2
votes
2 answers
Set Toast gravity top left in any textview android
I want to set my toast message at top|left position in any text view of my application so I used this code
public class CustomToast extends Activity {
TextView mTextView1;
TextView mTextView2;
@Override
protected void onCreate(Bundle…
user5474364
1
vote
0 answers
Android: proportional gravity
I have the following XML, which I use as a splash screen theme:
-

Nekomajin42
- 638
- 1
- 6
- 20
1
vote
1 answer
How to add a margin top to a bitmap?
This is the drawable file :
-
-

zeus
- 12,173
- 9
- 63
- 184
1
vote
0 answers
Why Android Lint strictly discourages the use of Gravity.LEFT or Gravity.RIGHT?
I understand that texts may be LEFT or RIGHT on different languages, so that END or START may be useful for international apps.
However, LEFT or RIGHT as Gravity are also simple placement of things. If I want my button or icon to be aligned to the…

htafoya
- 18,261
- 11
- 80
- 104
1
vote
0 answers
Android gravity is not working in drawable on older versions
I have a drawable which I am using in some scrolling fragment views. This is an image which should be sticky at the bottom of the page, should not scroll with the scroll view and should not stretch.
The drawable:

Otziii
- 2,304
- 1
- 25
- 34
1
vote
1 answer
android:gravity="center" not working on Samsung with big font size
I've been having an issue with the vertical alignment of the text inside a button, but only on Samsung devices. The problem is that when I go to the settings and set the maximum font size (from normal to huge, so the size changes across all the…

ulmaxy
- 820
- 2
- 14
- 22
1
vote
1 answer
Android AutoResizeTextView - Vertical Gravity off after resize
I'm using the AutoResizeTextView class found here. Auto Scale TextView Text to Fit within Bounds and it works great. However, I have the textview in a RelativeLayout and I have the layout_centerVertical property on the TextView set to true. Works…

Phil
- 4,029
- 9
- 62
- 107
1
vote
3 answers
Gravity set dynamically not working with Framelayout
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
params.gravity = Gravity.BOTTOM;
…

Anupriya
- 1,663
- 3
- 17
- 28