지원 라이브러리에서 GridLayout을 사용하고 있습니다. 일부 셀에는 플레이어 정보가 들어 있습니다. 두 개의 TextView가있는 선형 레이아웃을 사용합니다. 랩 할 이름 (두 번째 텍스트보기)을 가져올 수 없었습니다.force android TextView to wrap
현재 행동 :
123
John Cochtousczyon
원하는 동작 : 그리드에 그를 추가
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/player_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="test" />
<TextView
android:id="@+id/player_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:minLines="2"
android:scrollHorizontally="false"
android:text="testing thisout with extra sauce"
android:textSize="18sp" />
</LinearLayout>
및 코드 :
123
John
Cochtousczyon
여기에 현재 셀 레이아웃 XML의 상태입니다 :
lp = (GridLayout.LayoutParams) playerCell.getLayoutParams();
lp.columnSpec = GridLayout.spec(nameCol);
lp.rowSpec = GridLayout.spec(nameRow);
playerGrid.addView(playerCell, lp);
이상적으로 이름을 래핑 한 후 가장 넓은 셀의 열 너비를 설정하는 솔루션이 필요합니다. maxEms를 사용하여 원하는 결과에 가까워졌습니다. 그러나 긴 이름을 사용할 때 잘릴 수있는 정도에 대해 가장 필요한 필요 한도의 균형을 유지해야합니다.
P''R'''sa'''ll 거기에 대한 것이 아니라 너비를 해결하기 위해 - 그냥 밖으로 나가보다 똑똑한 모든 사람들 이이 문제를 해결할 경우 부탁드립니다.
제안 해 주셔서 감사합니다 ...이 경우 미리 작성된 문자열이 있으므로 CRLF를 삽입 할 수있는 기회가 없습니다. – ssdscott