ANDROID View alignment on layout -
i want center title "address" vertically within icon image, , want align content "st. lake 965" below title, there way it?
at moment have this:
<relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingtop="20dp" android:paddingbottom="20dp" android:paddingleft="10dp" android:paddingright="10dp"> <imageview android:layout_alignparenttop="true" android:layout_width="40dp" android:layout_height="20dp" android:id="@+id/pinpoint_icon" android:layout_centervertical="true" android:src="@drawable/pin_point_seller"/> <linearlayout android:layout_torightof="@id/pinpoint_icon" android:orientation="vertical" android:layout_width="match_parent" android:layout_marginleft="10dp" android:layout_height="wrap_content"> <textview android:layout_width="match_parent" android:textcolor="@color/gray" android:layout_height="wrap_content" android:text="address" android:singleline="true" android:gravity="left" android:textsize="18dp"/> <textview android:layout_margintop="10dp" android:id="@+id/fragment_profile_address_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="st. lake 965" android:gravity="left" android:textsize="18dp" android:layout_weight="1"/> </linearlayout> </relativelayout>
but if change icon height title "address" dont align vertically within icon
this result want:
the icon resized title stays centered vertically, , content below stay on same position
dont hardcode height , width
try this...
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingbottom="20dp" android:paddingleft="10dp" android:paddingright="10dp" android:paddingtop="20dp" > <imageview android:id="@+id/pinpoint_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centervertical="true" android:src="@drawable/pin_point_seller" /> <relativelayout android:id="@+id/address" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignbottom="@+id/pinpoint_icon" android:layout_aligntop="@+id/pinpoint_icon" android:layout_marginleft="10dp" android:layout_torightof="@id/pinpoint_icon" android:orientation="vertical" > <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centervertical="true" android:layout_gravity="center" android:singleline="true" android:text="address" android:textcolor="@android:color/black" android:textsize="18dp" /> </relativelayout> <textview android:id="@+id/sub_address" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/address" android:layout_below="@+id/address" android:layout_centervertical="true" android:layout_gravity="center" android:singleline="true" android:text="st. lake 965" android:textcolor="@android:color/black" android:textsize="18dp" /> </relativelayout>
Comments
Post a Comment