How can I get the dp(s) between View Group edge and a view edge like red arrows marked in the image below?
here is my layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/ll_select_gander"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".4"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="@dimen/margin_padding_double_standard">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/select_male_not_selected"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:text="@string/male"
android:textColor="@color/color_white"
android:textStyle="bold"
android:gravity="center"
android:textSize="@dimen/medium_text"
android:paddingTop="@dimen/margin_padding_standard"
android:paddingBottom="@dimen/margin_padding_standard"
android:layout_marginTop="@dimen/margin_padding_double_standard"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="@dimen/margin_padding_double_standard">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/select_female_not_selected"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:text="@string/female"
android:textColor="@color/color_white"
android:textStyle="bold"
android:gravity="center"
android:textSize="@dimen/medium_text"
android:paddingTop="@dimen/margin_padding_standard"
android:paddingBottom="@dimen/margin_padding_standard"
android:layout_marginTop="@dimen/margin_padding_double_standard"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_ribon"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".1"
android:background="@color/ribbon_color"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/margin_padding_double_standard"
android:text="@string/date_of_birth"
android:textColor="@color/theme_nevy_blue"
android:textSize="@dimen/large_text" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_select_dob"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".4"
android:orientation="vertical">
</LinearLayout>
You can add android:layout_weight="1"
and android:gravity="right"
to first(left) LinearLayout and add android:layout_weight="1"
and android:gravity="left"
to second(right) LinearLayout to archive similar result.
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_select_gander"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".4"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_padding_double_standard"
android:layout_weight="1"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/select_male_not_selected" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_padding_double_standard"
android:background="@color/colorPrimary"
android:gravity="center"
android:paddingBottom="@dimen/margin_padding_standard"
android:paddingTop="@dimen/margin_padding_standard"
android:text="@string/male"
android:textColor="@color/color_white"
android:textSize="@dimen/medium_text"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_padding_double_standard"
android:layout_weight="1"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/select_female_not_selected" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_padding_double_standard"
android:background="@color/colorPrimary"
android:gravity="center"
android:paddingBottom="@dimen/margin_padding_standard"
android:paddingTop="@dimen/margin_padding_standard"
android:text="@string/female"
android:textColor="@color/color_white"
android:textSize="@dimen/medium_text"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_ribon"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".1"
android:background="@color/ribbon_color"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/margin_padding_double_standard"
android:text="@string/date_of_birth"
android:textColor="@color/theme_nevy_blue"
android:textSize="@dimen/large_text" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_select_dob"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".4"
android:orientation="vertical">
</LinearLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.