Reputation: 2309
How to create the layout for android as on image?
I try next code:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="kkkkddd"
android:layout_marginLeft="100dp"
android:id="@+id/text_email" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prompt_email"
android:id="@+id/text_label_email"
android:layout_toLeftOf="@id/text_email" />
...
but label_email
is hidden.
Upvotes: 0
Views: 98
Reputation: 2185
make parent Linearlayout. And the use inner linearLayouts. In innerlayouts give gravity horizontal. then give .5 weight to its both childs i.e for "Email" textview & "[email protected]" weight should be .5 for both. set right alignment for "Email" and set left alignment for "[email protected]".
It will work perfectly.
Voteup or mark true if helpful
Upvotes: 0
Reputation: 2143
You should place your label-TextView first and set for it fixed width. Than place value-TextView to right of label:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/prompt_email"
android:id="@+id/text_label_email"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="kkkkddd"
android:toRightOf="@id/text_label_email"
android:id="@+id/text_email" />
Upvotes: 1
Reputation: 157487
Imo a LinearLayout would fit better for this purpose. For instance:
<LinearLayout
android:orienation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="kkkkddd"
android:layout_marginLeft="100dp"
android:id="@+id/text_email" />
<TextView
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="@string/prompt_email"
android:id="@+id/text_label_email"
android:layout_toLeftOf="@id/text_email" />
</LinearLayout>
and you could do this for each pair
Upvotes: 0