如何将一个视图覆盖到其他视图边缘android

时间:2017-03-23 10:13:54

标签: android android-layout

我想在直线上做一些直线,现在圆形图像有顶部和底部透明空间(图像本身)所以我想在第一个视图(圆形img)上覆盖底部视图(直线)所以它看起来像一条完整的直线。 这是我的代码。

        <com.bridgebuilder.app.customviews.BBCustomTextView
            android:id="@+id/txt_objective_met_minimally"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/objective_met_minimally"
            android:textColor="@color/colorPrimary"
            android:textSize="@dimen/attorney_review_header_text_size"
            app:fontFace="@string/font_medium" />


        <ImageView
            android:id="@+id/round_first_omm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/txt_objective_met_minimally"
            android:layout_marginTop="@dimen/layout_marginTop"
            android:src="@drawable/round" />

        <com.bridgebuilder.app.customviews.BBCustomTextView
            android:id="@+id/txt_not_completed"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:layout_alignTop="@id/round_first_omm"
            android:layout_alignBottom="@id/round_first_omm"
            android:layout_marginLeft="@dimen/left_margin_to_vertical_bar"
            android:layout_marginStart="@dimen/left_margin_to_vertical_bar"
            android:text="@string/not_completed"
            android:textSize="@dimen/text_size"
            app:fontFace="@string/font_medium" />


        <ImageView
            android:id="@+id/bar_first_omm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@id/round_first_omm"
            android:layout_alignLeft="@id/round_first_omm"
            android:layout_alignRight="@id/round_first_omm"
            android:layout_alignTop="@id/round_first_omm"
            android:layout_marginTop="5dp"
            android:layout_below="@id/round_first_omm"
            android:src="@drawable/line_small" />


        <ImageView
            android:id="@+id/round_second_omm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/bar_first_omm"
            android:layout_alignRight="@id/bar_first_omm"
            android:layout_below="@id/bar_first_omm"
            android:src="@drawable/round_selected"
            card_view:ignore="RtlHardcoded" />

        <com.bridgebuilder.app.customviews.BBCustomTextView
            android:id="@+id/txt_objective_somewhat_met"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@id/round_second_omm"
            android:layout_alignBottom="@id/round_second_omm"
            android:layout_marginLeft="@dimen/left_margin_to_vertical_bar"
            android:layout_marginStart="@dimen/left_margin_to_vertical_bar"
            android:gravity="center_vertical"
            android:text="@string/objective_somewhat_met"
            android:textSize="@dimen/text_size"
            app:fontFace="@string/font_medium" />


        <ImageView
            android:id="@+id/bar_second_omm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/round_second_omm"
            android:layout_alignRight="@id/round_second_omm"
            android:layout_alignTop="@id/round_second_omm"
            android:layout_marginTop="5dp"
            android:layout_below="@id/round_second_omm"
            android:src="@drawable/line_small" />


        <ImageView
            android:id="@+id/round_third_omm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/bar_second_omm"
            android:layout_alignRight="@id/bar_second_omm"
            android:layout_below="@id/bar_second_omm"
            android:src="@drawable/round"
            card_view:ignore="ContentDescription" />

        <com.bridgebuilder.app.customviews.BBCustomTextView
            android:id="@+id/txt_objective_met"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@id/round_third_omm"
            android:gravity="center_vertical"
            android:layout_alignTop="@id/round_third_omm"
            android:layout_alignBottom="@id/round_third_omm"
            android:layout_marginLeft="@dimen/left_margin_to_vertical_bar"
            android:layout_marginStart="@dimen/left_margin_to_vertical_bar"
            android:text="@string/objective_meet"
            android:textSize="@dimen/text_size"
            app:fontFace="@string/font_medium" />


        <ImageView
            android:id="@+id/bar_third_omm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@id/round_third_omm"
            android:layout_marginTop="5dp"
            android:layout_below="@id/round_third_omm"
            android:src="@drawable/line_small"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignRight="@+id/round_third_omm"
            android:layout_alignEnd="@+id/round_third_omm" />


        <com.bridgebuilder.app.customviews.BBCustomTextView
            android:id="@+id/txt_completed_impressive"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:layout_alignTop="@id/round_fourth_omm"
            android:layout_alignBottom="@id/round_fourth_omm"
            android:layout_marginLeft="@dimen/left_margin_to_vertical_bar"
            android:layout_marginStart="@dimen/left_margin_to_vertical_bar"
            android:text="@string/completed_slash_impressive"
            android:textSize="@dimen/text_size"
            app:fontFace="@string/font_medium" />

        <ImageView
            android:id="@+id/round_fourth_omm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/round"
            android:layout_alignRight="@+id/bar_third_omm"
            android:layout_alignEnd="@+id/bar_third_omm"
            android:layout_below="@+id/bar_third_omm"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />


    </RelativeLayout>

在图像(图像下方)中,圆形图像和线条之间似乎存在空间,因此我想重叠图像的边缘,使其看起来像是连接的

enter image description here

1 个答案:

答案 0 :(得分:1)

您已将上限设置为5 dp,这可能会导致此行为。

尝试删除它,这应该有助于提供您所期望的外观

注意:我假设实际图像中没有边距

<ImageView
            android:id="@+id/bar_third_omm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@id/round_third_omm"
            android:layout_below="@id/round_third_omm"
            android:src="@drawable/line_small"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignRight="@+id/round_third_omm"
            android:layout_alignEnd="@+id/round_third_omm" />

删除保证金