layout-gravity

How to right-align text in an Android TextView or EditText?

余生长醉 提交于 2019-11-29 16:34:10
问题 I have an EditText in my application. I want to align the text in it to the right instead of the default left. I tried adding android:layout_gravity="right" but this doesn't seem to work. any other suggestions please? 回答1: You should use android:gravity="right" . layout_gravity is for the view (EditText) alignment against the container. 回答2: You may use android:layout_alignParentRight="true" to align the EditText's right edge to its parent's right edge. Also, if you really want to use the

What is exact difference between gravity and layout_gravity [duplicate]

无人久伴 提交于 2019-11-29 11:54:15
问题 Possible Duplicate: Android - gravity and layout_gravity I have been working on android xml's. I have used android:layout_gravity="center" to align components in specific position. Now a days, when I was working on a Dialog like Activity , I came across android:gravity="center" . What I found there was, gravity was used to align its child to a specific position. I would share an example of what it is, android:gravity="center" <LinearLayout android:layout_width="match_parent" android:layout

Android - Set Layout_Gravity programmatically for LinearLayout

折月煮酒 提交于 2019-11-29 01:42:34
I've got the following problem: I implemented a HorizontalScrollView which contains in one case a LinearLayout and an ImageView . In this case the image is about 50% of the screen width. So I want to center it. Unfortunately the only way I found to center it is, to use layout_gravity="center" on the LinearLayout . Here's my xml: <HorizontalScrollView android:layout_gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android

Text/Layout Alignment in Android (textAlignment, gravity)

旧时模样 提交于 2019-11-28 20:02:42
What's the difference between android:textAlignment and android:gravity ? stinepike All I can see is that the textAlignment is a member of the View Class and the gravity is the member of TextView class. So for the TextView and its subclasses you can use the gravity while you can use the textAlignment for all Views. As the TextView and its subclasses need some more text-aligning features, so you can see there are more options in gravity where in textAlignment there are only basic options. Although it is only my guess because I have not found any clear documentation about the difference. You can

layout_gravity in LinearLayout

 ̄綄美尐妖づ 提交于 2019-11-27 19:26:39
This is my layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_marginLeft="5dip" /> <TextView

Android - Set Layout_Gravity programmatically for LinearLayout

送分小仙女□ 提交于 2019-11-27 16:12:33
问题 I've got the following problem: I implemented a HorizontalScrollView which contains in one case a LinearLayout and an ImageView . In this case the image is about 50% of the screen width. So I want to center it. Unfortunately the only way I found to center it is, to use layout_gravity="center" on the LinearLayout . Here's my xml: <HorizontalScrollView android:layout_gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation=

How to set both gravity and layout gravity of a LinearLayout programatically

a 夏天 提交于 2019-11-27 14:52:17
I am risking writing a duplicate question, but as I was researching the answer to another SO question , I realized that I couldn't find a simple question and answer that included setting both gravity and layout_gravity of a LinearLayout . Also, I was confused as to the difference between them when talking about a ViewGroup rather than just a view. I am answering my question below. Here are some of the other questions I viewed: How to set gravity to layout programmatically? Set gravity for LinearLayout programmatically android - setting LayoutParams programmatically LayoutParams gravity not

Text/Layout Alignment in Android (textAlignment, gravity)

北城以北 提交于 2019-11-27 01:12:49
问题 What's the difference between android:textAlignment and android:gravity ? 回答1: All I can see is that the textAlignment is a member of the View Class and the gravity is the member of TextView class. So for the TextView and its subclasses you can use the gravity while you can use the textAlignment for all Views. As the TextView and its subclasses need some more text-aligning features, so you can see there are more options in gravity where in textAlignment there are only basic options. Although

How to set both gravity and layout gravity of a LinearLayout programatically

落爺英雄遲暮 提交于 2019-11-26 16:56:16
问题 I am risking writing a duplicate question, but as I was researching the answer to another SO question, I realized that I couldn't find a simple question and answer that included setting both gravity and layout_gravity of a LinearLayout . Also, I was confused as to the difference between them when talking about a ViewGroup rather than just a view. I am answering my question below. Here are some of the other questions I viewed: How to set gravity to layout programmatically? Set gravity for