확인란의 텍스트를 포장하지 않도록 어떻게 강요 할 수 있습니까?
-
21-12-2019 - |
문제
이것은 LinearLayout (가로) 행이 다음과 같습니다 :
Checkbox의 텍스트가 한 줄에있는 텍스트를 원합니다.버튼은 그 넓을 필요가 없습니다. 체크 박스 텍스트가 조금 길어 졌던 공간이 많이있을 것입니다.내 XML에서 무엇 :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/ckbxAllow_New_Items"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:checked="true"
android:text="@string/checkbox_Allow_New_Items" />
<Button
android:id="@+id/btnOK"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/button_OK" />
<Button
android:id="@+id/btnCancel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/button_Cancel" />
</LinearLayout>
.
... 내 확인란 텍스트를 포장하지 않도록하려면 변경해야합니까?
업데이트
이 다음과 같은 Golem의 제안 :
android:lines="1"
.
... 그리고 1에서 2까지의 체크 상자의 layout_weight를 변경 (버튼의 경우 1로 설정) 내가 원하는 것을 알려 줬습니다.
해결책
checkbox는 textview 를 상속받는 버튼을 상속받는 compoundButton에서 상속받습니다. 그래서, 그것은이 조상의 모든 속성, 방법 및 속성을 가지고 있습니다 <<
참조 : "noreferrer"> http://developerrer"> http://developer.android.com/reference/android/widget/checkbox. .html
특히 textview 속성, 메소드 및 속성에 관심이 있습니다. 참조 : http://developer.android.com/reference/android/widget/textview. .html
특히 android:lines
속성에 관심이 있으며 1 로 설정하십시오.
이렇게하면 체크 박스가 정확히 1 라인 키가
android:ellipsize
속성을 일부 값 (즉, 3= 끝)으로 설정하려는 경우도 있습니다.
따라서 잘린 텍스트의 끝, 시작, 센터, ...
[편집]
TextView의 미리 탐색 인 @crandellws 덕분에 setSingleLine
를 사용할 수 있습니다.