2016-09-29 5 views
0

안녕하세요 저는 그림을 표시해야하며 그 아래에 이름을 표시하는 horizontal recyclerView가 있습니다. 크기가 고정되어 있고 아래의 텍스트가 보이지 않거나 이상하게 배치되었지만 이미지보기가 다른 크기로 나타나는 것처럼 작동하지 않습니다. 아래는 에뮬레이터와 휴대 전화의 스크린 샷입니다.목록 항목보기가 Linear RecyclerView에 올바르게 표시되지 않습니다.

image form emulator

image from phone while loading (you can see the text behind??)

image from phone after loading

코드 :

recyclerview이

<android.support.v7.widget.CardView 
       android:id="@+id/more_cardView_2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       tools:visibility="visible" 
       android:visibility="invisible" 
       android:layout_marginRight="8dp" 
       android:layout_marginLeft="8dp" 
       android:layout_marginBottom="8dp"> 

       <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_marginLeft="8dp" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textStyle="bold" 
         android:textColor="@android:color/black" 
         android:text="Cast" 
         android:layout_marginBottom="4dp"/> 

        <android.support.v7.widget.RecyclerView 
         android:layout_marginLeft="8dp" 
         android:layout_marginRight="8dp" 
         android:layout_marginBottom="8dp" 
         android:id="@+id/cast_recyclerView" 
         android:layout_width="wrap_content" 
         android:layout_height="135dp"> 


        </android.support.v7.widget.RecyclerView> 
       </LinearLayout> 

      </android.support.v7.widget.CardView> 
,691,363
을 위치한 cardView을 (210)

수평 재활용보기에 대한 LIST_ITEM의 XML

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:orientation="vertical" 
       android:layout_width="100dp" 
       android:background="#E0E0E0" 
       android:layout_height="135dp"> 

    <ImageView 
     android:id="@+id/profile_pic" 
     tools:background="@android:color/black" 
     tools:src="@drawable/test" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="centerInside"/> 

    <TextView 
     android:layout_marginTop="5dp" 
     android:id="@+id/actor_name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:singleLine="true" 
     android:maxLines="1" 
     android:ellipsize="end" 
     android:textColor="@android:color/black" 
     android:textStyle="bold" 
     tools:text="The name of an actor" 
     android:textSize="12sp" 
     /> 

    <TextView 
     android:id="@+id/actor_role" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:singleLine="true" 
     android:maxLines="1" 
     android:ellipsize="end" 
     tools:text="The character playd by that actor" 
     android:textSize="12sp" 

     /> 


</LinearLayout> 

The preview of this file (this is the correct one taht should be displayed)

답변

2

, 다음과 같이 수행 할 수 있습니다

LinearLayoutManager horizontalLayoutManagaer 
      = new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false); 
cast_recyclerView.setLayoutManager(horizontalLayoutManagaer); 
cast_recyclerView.setAdapter(horizontalAdapter); 

을 그리고 당신의 LIST_ITEM .XML을 변경 다음에 :

,451,515,
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" 
    android:layout_width="wrap_content" 
    android:background="#E0E0E0" 
    android:layout_height="wrap_content"> 

    <ImageView 
     android:id="@+id/profile_pic" 
     tools:background="@android:color/black" 
     tools:src="@drawable/test" 
     android:layout_width="100dp" 
     android:layout_height="135dp" 
     android:scaleType="centerCrop"/> 

    <TextView 
     android:layout_marginTop="5dp" 
     android:layout_gravity="center" 
     android:id="@+id/actor_name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:singleLine="true" 
     android:maxLines="1" 
     android:ellipsize="end" 
     android:textColor="@android:color/black" 
     android:textStyle="bold" 
     tools:text="The name of an actor" 
     android:textSize="12sp"/> 

    <TextView 
     android:id="@+id/actor_role" 
     android:layout_gravity="center" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:singleLine="true" 
     android:maxLines="1" 
     android:ellipsize="end" 
     tools:text="The character playd by that actor" 
     android:textSize="12sp"/> 
</LinearLayout> 

은 또한 당신의 cardView에 다음에 recyclerview을 변경

<android.support.v7.widget.RecyclerView 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:layout_marginBottom="8dp" 
     android:id="@+id/cast_recyclerView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
</android.support.v7.widget.RecyclerView> 
+0

덕분에 나는 일이있어 약간의 조정과 함께. – fgoogle

+0

@fgoogle에 오신 것을 환영합니다. 도움이된다면 답을 올리십시오. – Ayan