해당 뷰의 레이아웃이 wrap_content 일 때 내 RecyclerView에서 내 뷰가 사라지는 문제가 있습니다. RecyclerView는 양방향 match_parent이며 아래 xml 파일을 확장하는 LinearLayout을 사용합니다. RecyclerView의 각 부분은 다음과 같습니다.
여기에 대한 XML이 있습니다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<View
android:id="@+id/scheduleBlockColor"
android:layout_width="15dp"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/scheduleBlockText"
android:background="@color/colorCougarRed" />
<RelativeLayout
android:id="@+id/scheduleBlockText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/scheduleBlockColor"
android:layout_toRightOf="@id/scheduleBlockColor"
android:paddingEnd="0dp"
android:paddingLeft="5dp"
android:paddingRight="0dp"
android:paddingStart="5dp">
<TextView
android:id="@+id/scheduleBlockTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="@string/schedule_block_time_default"
android:textSize="16sp" />
<TextView
android:id="@+id/scheduleBlockClassName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/scheduleBlockTime"
android:ellipsize="end"
android:padding="2dp"
android:singleLine="true"
android:text="@string/schedule_block_class_default"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/scheduleBlockRoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/scheduleBlockClassName"
android:padding="2dp"
android:text="@string/schedule_block_room_default"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
내 질문은 RecyclerView가로드 될 때 해당 컬러 조각이 사라지지 않도록하려면 어떻게해야합니까? 위의 부모 RelativeLayout이 match_parent로 설정되어 있으면 제대로 작동합니다. 이 답변을 시도했지만 같은 성공을 거두지 못했습니다.
에 설정된 높이 때문입니다 <View>
. match_parent
콘텐츠가 없다는 사실 때문에 엉망 이됩니다. 의도는 세로 스트라이프를 갖는 것이므로 부모의 상단과 하단에 고정 할 수 있습니다. 이미 하단 부분 (텍스트보기 컨테이너의 하단에 정렬)에 대해 수행하고 있으므로 상단 고정 만 처리하면됩니다.
<View
android:id="@+id/scheduleBlockColor"
...
android:layout_alignParentTop="true"
... />
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다