anze87
anze87

Reputation: 253

How to place start edge of EditText in center horizontal of screen?

I need and I can't find solution for placing EditText element from center of horizontal line in relative layout? Like android:layout_alignParentRight="true", I would need something like layout_alignParentCenterHorizontal. Is there something like that? thanks for help!

Upvotes: 0

Views: 124

Answers (1)

Graham Povey
Graham Povey

Reputation: 949

I'd create an invisible, minimum width item centered horizontally, and then place my EditText relative to that. Use INVISIBLE instead of GONE for the visibility property for this to work. e.g.

<TextView
   android:id="@+id/centerLine"
   android:layout_width="1dip"
   android:layout_height="match_parent"
   android:layout_centerHorizontal="true"
   android:visibility="invisible"
   />

<EditText
   ...
   android:layout_toRightOf="@id/centerLine"
   ...
   />

Upvotes: 1

Related Questions