RelativeLayout内的视图/布局在PreLollipop设备中不可见

时间:2016-01-08 11:38:17

标签: android android-layout android-relativelayout

预先Views设备上无法显示

RelativeLayout / Lollipop。我也尝试使用颜色资源而不是可绘制资源。之前我在View内尝试使用RelativeLayout,但没有效果。 View / Layout内部的硬编码宽度为5 dp

<RelativeLayout
android:id="@+id/side_line1"
android:layout_alignTop="@+id/subject_content"
android:layout_alignBottom="@+id/subject_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>

<RelativeLayout
    android:layout_width="5dp"
    android:layout_height="match_parent"
    android:layout_marginTop="8dp"
    android:layout_marginLeft="@dimen/pad_8_dp"
    android:background="@drawable/bg_rect_round_corner_orange"
    android:id="@+id/side_line_1"
    android:visibility="visible"
    android:layout_alignParentTop="true"
    android:layout_centerInParent="true"
    ></RelativeLayout>

<RelativeLayout
    android:layout_width="5dp"
    android:layout_height="match_parent"
    android:layout_marginTop="8dp"
    android:layout_marginLeft="@dimen/pad_8_dp"
    android:background="@drawable/bg_rect_round_corner_orange"
    android:visibility="gone"
    android:id="@+id/side_line_1_colored"
    android:layout_alignParentTop="true"
    android:layout_centerInParent="true"
    ></RelativeLayout>

<include
    android:id="@+id/step_one"
    android:layout_width="20dp"
    android:layout_height="20dp"
    layout="@layout/layout_step"
    />

</RelativeLayout>

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

更改

<RelativeLayout
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginLeft="@dimen/pad_8_dp"
android:background="@drawable/bg_rect_round_corner_orange"
android:id="@+id/side_line_1"
android:visibility="visible"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
></RelativeLayout>

<RelativeLayout
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginLeft="@dimen/pad_8_dp"
android:background="@drawable/bg_rect_round_corner_orange"
android:visibility="gone"
android:id="@+id/side_line_1_colored"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
></RelativeLayout>

<RelativeLayout
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginLeft="@dimen/pad_8_dp"
android:background="@drawable/bg_rect_round_corner_orange"
android:id="@+id/side_line_1"
android:visibility="visible"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
/>

<RelativeLayout
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginLeft="@dimen/pad_8_dp"
android:background="@drawable/bg_rect_round_corner_orange"
android:visibility="gone"
android:id="@+id/side_line_1_colored"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
/>

这应该可以正常工作。