나는 모든 항목이 텍스트 필드 만 포함하고 다른 것은 아무것도 사용하지 않는 간단한 ListView
을 사용하고 있습니다. 여기안드로이드 어떻게 내용을 수용하기 위해 목록 항목 높이를 높이는 방법
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="@drawable/bg_card">
<TextView
android:id="@+id/txt"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:textSize="15sp"
android:paddingLeft="6dip"
android:textColor="#878787"
android:textIsSelectable="true"/>
</LinearLayout>
</FrameLayout>
및 목록보기를 사용하여 조각에 대한 내 레이아웃은 다음과 같습니다 다음은 목록 항목에 대한 내 XML 코드입니다. 나는 텍스트 즉 두 번째 매개 변수에 매우 긴 문장이있는 경우이
Level weather_data[] = new Level[] {
new Level(R.drawable.s1,
"Some text which will be present in the list item",
R.drawable.play_button)
};
처럼 내 조각에 어댑터의 객체를 생성하는 동안 이제
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e5e5e5">
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:dividerHeight="0dp"
android:divider="@null"/>
</RelativeLayout>
, 그것의 일부는하지 않습니다 표시되고 문장이 목록 항목에 불완전하게 표시됩니다.
android:minHeight
을 사용하여 목록 항목의 높이를 변경하려고 시도했지만 작동하지 않았습니다. 이것에 대한 해결책은 무엇일까요? 감사합니다
당신이 그것을 텍스트의 크기를 취할 WrapContent 50dp.Make와 텍스트 뷰의 높이를 준 때문입니다 같아요. –
@ user2012 아니요, 여전히 차이가 없습니다. –
시험해보십시오. http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds – VikramV