2017-11-24 1 views
1

리사이클 러 뷰에 사용자 정의 어댑터가 있고 리사이클 뷰에 뉴스가 표시됩니다. 그것의 완벽하게 작동하지만 주어진 스크린 샷처럼 보여줍니다. 코드 예제가 단계별로 필요합니다. 내가 어떻게 성취 할 수 있겠 어. 리사이더 뷰용 사용자 정의 xml 코드하나의 리사이클 뷰에서 다른 스타일

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_margin="5dp" 
android:background="#30000000"> 

<ImageView 
    android:id="@+id/iv_news" 
    android:layout_width="match_parent" 
    android:layout_height="160dp" /> 
<TextView 
    android:id="@+id/tv_news_title" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textColor="@color/black" 
    android:layout_marginTop="5dp" 
    android:padding="5dp" 
    android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" 
    /> 
</LinearLayout> 

스크린 샷 이제이 enter image description here

처럼 표시하지만 난 당신이 당신의 선에 수평 대신 수직의 당신의 선형 레이아웃의 방향을 설정하기 위해 필요한이 enter image description here

+1

그래서있을거야 하나 개의 항목이 개 동일한 행의 항목 후 1 단 다음에 대한 match_parent 다시 항목? 그리고 이것은 계속 되풀이 될 것입니까? – rafid059

+0

[여러보기 유형으로 RecyclerView를 만드는 방법?] (https://stackoverflow.com/questions/26245139/how-to-create-recyclerview-with-multiple-view-type) – rafid059

+1

@ rafid059 예. –

답변

0

처럼 표시 할 위의 레이아웃. android:orientation="horizontal"dp의 폭을 지정하기보다는 이미지 뷰와 텍스트 뷰

`

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_margin="5dp" 
android:background="#30000000"> 

<ImageView 
android:id="@+id/iv_news" 
android:layout_width="50dp" 
android:layout_height="160dp" /> 

<TextView 
android:id="@+id/tv_news_title" 
android:layout_width="wrap_ content" 
android:layout_height="wrap_content" 
android:textColor="@color/black" 
android:layout_marginTop="5dp" 
android:padding="5dp" 
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" 
/> 

</LinearLayout> 

`

+1

스크린 샷을 확인하십시오. 하나의 리사이클 뷰에 여러 디자인을 표시하고 싶습니다. –

관련 문제