TextViews
에 짧은 문장을 사용해야합니다. 나는 recyclerView
을 GridLayoutManager
으로 사용하고 그리드의 각 셀에있는 TextView
에 각 문장을 설정했습니다. 것은 격자의 각 셀이 TextView
의 텍스트에 따라 너비를 변경하고 싶습니다. 즉, 긴 문장은 화면을 전체 너비로 가져갈 수 있습니다. 또는 문장이 매우 짧은 경우 동일한 줄에 있어야합니다.recyclerview에서 내부 텍스트 길이에 따라 열 너비가 변경되는 방법
또한 GridView
을 사용해 보았지만 원하는 결과를 얻지 못했습니다.
어떻게 얻는 지 알고 싶습니까?
EDIT
item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/unselected_term"
android:padding="10dp">
<TextView
android:id="@+id/item_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/term_text"
android:gravity="center"
android:textSize="18sp"/>
</LinearLayout>
EDIT 2
이것은 레이아웃이 어떻게 표시되는지 예입니다. 각 요소의 길이는 항상 같지 않습니다. 그래서 더 큰 너비가 더 짧은 너비를 갖는 레이아웃을 필요로합니다.
여기에 xml을 게시 할 수 있습니까? 귀하가 recyclerview 항목 – Umair
에 사용중인 레이아웃 @Umair Code added : –
답변을 업데이트했습니다. 귀하를 위해 작동하는지 확인하고 알려주십시오. – Umair