0

왜 내 listItem이 이상한 방식으로 렌더링되는지 알 수 없습니다. 나는 제약 조건을 점검하고 모든 것이 잘된 것처럼 보입니다. 여기 내 listItem의 리사이클 뷰에 이상한 렌더링

enter image description here

enter image description here

레이아웃에 대한 내 XML입니다 : : 여기

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/list_item_container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    tools:layout_editor_absoluteY="81dp" 
    tools:layout_editor_absoluteX="0dp"> 

    <ImageView 
     android:id="@+id/customer_picture" 
     android:layout_width="50dp" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="16dp" 
     app:srcCompat="@mipmap/ic_launcher" 
     app:layout_constraintTop_toTopOf="parent" 
     android:layout_marginTop="8dp" 
     android:layout_marginLeft="8dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     android:layout_marginBottom="8dp"/> 

    <TextView 
     android:id="@+id/customer_name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginEnd="8dp" 
     android:layout_marginLeft="0dp" 
     android:layout_marginRight="8dp" 
     android:layout_marginTop="8dp" 
     app:layout_constraintLeft_toRightOf="@+id/customer_picture" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     tools:text="First Name: Last Name:"/> 

    <TextView 
     android:id="@+id/customer_address" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginEnd="8dp" 
     tools:text="1543 W Kendall Blvd" 
     app:layout_constraintLeft_toRightOf="@+id/customer_picture" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="8dp" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintHorizontal_bias="0.425" 
     android:layout_marginBottom="8dp"/> 
</android.support.constraint.ConstraintLayout> 

컨테이너입니다 저는 여기에 런타임 대 디스플레이시에지고있어 무엇의 사진입니다 XML :

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" 
     android:layout_marginLeft="8dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     android:layout_marginBottom="8dp" 
     android:layout_marginStart="8dp"/> 

    <Button 
     android:id="@+id/button4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" 
     android:layout_marginRight="8dp" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     android:layout_marginBottom="8dp" 
     android:layout_marginEnd="8dp"/> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/customer_recycler_view" 
     android:layout_width="0dp" 
     android:layout_height="380dp" 
     android:layout_marginRight="8dp" 
     app:layout_constraintRight_toRightOf="parent" 
     android:layout_marginLeft="8dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:layout_marginTop="8dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     android:layout_marginBottom="65dp"/> 
</android.support.constraint.ConstraintLayout> 

나는 또한 컨테이너를 v (단편)을 포함하는 활동으로 보아라. 내 어댑터와 RecyclerView에 대한 ViewHolder 클래스를 게시 할 수 있습니다

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.bignerdranch.android.personaltrainer.ListActivity"> 

    <LinearLayout 
     android:layout_width="304dp" 
     android:layout_height="wrap_content" 
     android:id="@+id/logged_in_fragment_container" 
     android:orientation="horizontal" 
     android:layout_marginLeft="8dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:layout_marginRight="8dp" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:layout_marginTop="8dp" 
     tools:layout_height="18dp" 
     android:layout_marginBottom="8dp" 
     app:layout_constraintBottom_toTopOf="@+id/list_fragment_container"> 

    </LinearLayout> 

    <android.support.constraint.ConstraintLayout 
     android:id="@+id/list_fragment_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginBottom="8dp" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:layout_marginTop="34dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent"> 

    </android.support.constraint.ConstraintLayout> 

</android.support.constraint.ConstraintLayout> 

하지만 아마 필요가 없습니다 나에게 의미

+0

는 왜해야합니까 행 항목 레이아웃의 루트 요소에이를 설정할 수 있습니다, 귀하의 의견은

또는 목록 내에서 확대되고있는 것 같다 일부보기의 너비와 높이에 대한 상수? –

+0

그게 다야 !!! 고마워, 나는 너에게 나의 관심을 끌기 위해 뭔가를 줄 수 있기를 바란다. 그것은 Android Studio가 저에게 변경된 것입니다. 나는 때때로 AS가 약간 버그가 될 수 있다는 것을 알아 챘다. 나는 원래 Recyclerview의 높이와 listItem의 이미지 뷰에서 "감싸는 내용"을 가졌지 만 어떻게 든 AS는 그것을 계속 변경합니다. 이제 멋지 네요! 덕분에 –

+0

멋지다, 그것이 유일한 문제인지 확실하지 않았다. 내 대답을 수락 해주십시오. –

답변

1

뭔가가 있다는 것입니다 : 그것은 할 수 있지만, 여기에 활동하는 경우 나도 몰라 RecyclerView는 고정 된 높이와 너비가 없습니다. 이를 바탕으로

<android.support.v7.widget.RecyclerView 
    android:id="@+id/customer_recycler_view" 
    android:layout_width="0dp" 
    android:layout_height="380dp" 

, 당신이

android:height="?android:attr/listPreferredItemHeight" 
관련 문제