Android: TextViews next to each other on different screen sides -
i'm struggling textviews
. want them next each other in opposite screen sides. first should on left of screen , second on right. code:
<linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <textview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/unit" android:textsize="22sp" android:text="unit"/> <textview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/unitname" android:text="km" android:textcolor="@android:color/darker_gray" android:textsize="22sp"/> </linearlayout>
i tried layout_gravity
, gravity
, doesn't work. experimenting wrap_content
, match_parent
still textviews
next each other. want them in opposite screen sides. should do?
change width wrap_content , linear layout relativelayout , set alignparent attributes
<relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <textview android:layout_width="wrap_content" android:layout_height="match_parent" android:id="@+id/unit" android:layout_alignparentleft="true" android:textsize="22sp" android:text="unit"/> <textview android:id="@+id/unitname" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="right" android:layout_alignparentright="true" android:text="km" android:textcolor="@android:color/darker_gray" android:textsize="22sp" /> </relativelayout>
Comments
Post a Comment