Reputation: 10472
Here is my layout which does a good job of centering the hint, but how do I make the hint left justified with say a margin of 10dip ?, (ie I want to keep it centered vertically but also left justified)
<EditText
android:id="@+id/mobilePhoneNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:inputType="number"
android:ellipsize="start"
android:gravity="center"
android:layout_marginTop="10dip"
android:hint="@string/lbl_hint_enter_mobile_phone_number"
android:textSize="14dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:maxLines="1" />
Upvotes: 3
Views: 11538
Reputation: 33741
<EditText
android:id="@+id/mobilePhoneNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:ellipsize="start"
android:gravity="left|center_vertical"
android:paddingLeft="5dp"
android:layout_marginTop="10dip"
android:hint="hello world"
android:textSize="14dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:maxLines="1" />
Upvotes: 12
Reputation: 5960
You need padding, not margin:
android:paddingLeft="10dip"
android:paddingRight="10dip"
and if you do not want center horizontal, set gravity to "center_vertical".
Upvotes: 3