반응형
EditText 상자 높이를 확장하는 방법
내 레이아웃은 다음과 같습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/etTweetReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:ems="10"
android:hint="Discuss up to 140 characters"
android:imeOptions="actionDone"
android:inputType="textCapSentences"
android:lines="2"
android:maxLength="140"
android:paddingBottom="10dp"
android:singleLine="false" />
<Button
android:id="@+id/theReviewBarButton"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:text="Submit Review"
android:textSize="22sp" />
<Spinner
android:id="@+id/spinnerSort"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:scrollbars="none"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp" >
</ListView>
</LinearLayout>
그 EditText 상자가 끝날 때 다음 줄로 줄 바꿈하고 싶습니다. 지금은 화면에서 남은 모든 것을 계속 오른쪽으로 이동합니다.
다른 질문과 유사합니다.
Android Word-Wrap EditText 텍스트
다음은 XML 코드의 몇 가지 예입니다.
<EditText
android:id="@+id/edtInput"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/compose_hint"
android:inputType="textCapSentences|textMultiLine"
android:maxLength="2000"
android:maxLines="4" />
처음에 한 줄만 사용하고 5 줄로 확장하고 최대 10 줄을 원한다고 가정합니다.
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/etMessageBox"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:autoLink="all"
android:hint="@string/message_edit_text_hint"
android:lines="5"
android:minLines="1"
android:gravity="top|left"
android:maxLines="10"
android:scrollbars="none"
android:inputType="textMultiLine|textCapSentences"/>
증가함으로써 android:lines
당신은 얼마나 많은 줄을 확장 할 수 있습니다.
android : lines = "6"을 편집 텍스트에 추가하기 만하면됩니다.
<Edittext
android:id="@+id/edt_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:maxLines="6"
android:lines="6"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:gravity="left"/>
이 코드를 시도
<EditText
android:id="@+id/"edittext01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textCapSentences|textMultiLine"
android:maxLength="100"
android:maxLines="10"/>
EditText
높이 설정이 필요합니다.android:layout_height="wrap_content"
&
android:lines="5"
이것은 나를 위해 속임수를 썼습니다. ConstraintLayout
EditText에서이 줄을 제거하십시오.
android:inputType="textCapSentences"
이 줄에 필요한 줄 수를 추가하십시오.
android:lines="2"
이것이 도움이되기를 바랍니다.
참고URL : https://stackoverflow.com/questions/12537819/how-to-make-edittext-box-height-expand
반응형
'Program Tip' 카테고리의 다른 글
콘솔 응용 프로그램의 경우 "종료시" (0) | 2020.11.17 |
---|---|
기존 DataTable에 값이있는 새 열을 추가하는 방법은 무엇입니까? (0) | 2020.11.17 |
gsub로 여러 글자를 악센트로 대체 (0) | 2020.11.16 |
React 컴포넌트의 상태에 객체를 저장합니까? (0) | 2020.11.16 |
vim의 명령 기록을 어떻게 검색합니까? (0) | 2020.11.16 |