편집 텍스트에 setText를 사용하여 편집 양식에 데이터를로드하는 편집 텍스트가 있습니다. 현재 editText 높이가 고정되어 있으며 텍스트가 editText 높이보다 크면 전체 텍스트를 한 번에 볼 수 없습니다. 콘텐츠를 기반으로하는 방법이 있습니까? 나는 EditText의 높이를 동적으로 설정할 수 있습니다.콘텐츠를 기준으로 EditText의 높이를 동적으로 설정합니다.
당신의 도움에 미리 감사와
감사 R은
편집 텍스트에 setText를 사용하여 편집 양식에 데이터를로드하는 편집 텍스트가 있습니다. 현재 editText 높이가 고정되어 있으며 텍스트가 editText 높이보다 크면 전체 텍스트를 한 번에 볼 수 없습니다. 콘텐츠를 기반으로하는 방법이 있습니까? 나는 EditText의 높이를 동적으로 설정할 수 있습니다.콘텐츠를 기준으로 EditText의 높이를 동적으로 설정합니다.
당신의 도움에 미리 감사와
감사 R은
다음과 같은 텍스트를 편집의 높이를 설정하려고 제안 :
android:layout_height="wrap_content"
시도를,이 도움이 될 수 - :
edittext.getLayoutParams().width=50
et= (CustomEditText) findViewById(R.id.et);
ViewGroup.LayoutParams lp = et.getLayoutParams();
lp.width = 100;
lp.height = 100;
et.setLayoutParams(lp);
당신은 당신의 XML 파일이 코드를 사용할 수 있습니다 : 당신의 텍스트를 편집 포함
<EditText
android:id="@+id/edtFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/first_name"
android:padding="5dp"
android:textColor="@color/black"
android:textSize="16sp" />
동안 자동으로 테스트 크기에 맞게 제공됩니다.
는
android:layout_height
wrap_content
이 가장 좋은 방법입니다
android:singleLine="true"
또는
android:minLines="1"
및
android:maxLines="1"
설정을 사용하지 마십시오.
보기는 콘텐츠를 감싸기에 충분해야합니다.
사용 DisplayMetrics
동적 에 대한 글고의 높이를 설정합니다.
DisplayMetrics metrics = getResources().getDisplayMetrics();
int DeviceTotalWidth = metrics.widthPixels;
int DeviceTotalHeight = metrics.heightPixels;
어떻게?
이android:layout_height ="wrap_content"
및 android:inputType="textMultiLine"
사용이 당신을 도울 수는
if(length()>n) // n is your String length
editTEXT.getLayoutParams().height=DeviceTotalHeight*10/100;
, 난 당신이 의 부모 레이아웃으로 ScrollView
를 사용하는 것이 좋습니다 것입니다
<EditText
android:id ="@+id/editText"
android:layout_width ="match_parent"
android:layout_height ="wrap_content"
android:inputType="textMultiLine"
android:hint ="Hint"
android:scrollHorizontally="false" />
최선의 방법에게 있습니다당신이있을 때3210
이 큰
text
나에게 글고 치기에 대한 XML 코드를 보여 화면에서 (화면에서 외부) 차단하기 위해EditText
을 방지 –