0

나는 모든 항목이 텍스트 필드 만 포함하고 다른 것은 아무것도 사용하지 않는 간단한 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을 사용하여 목록 항목의 높이를 변경하려고 시도했지만 작동하지 않았습니다. 이것에 대한 해결책은 무엇일까요? 감사합니다

+0

당신이 그것을 텍스트의 크기를 취할 WrapContent 50dp.Make와 텍스트 뷰의 높이를 준 때문입니다 같아요. –

+0

@ user2012 아니요, 여전히 차이가 없습니다. –

+0

시험해보십시오. http://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds – VikramV

답변

0

용기를 wrap_content으로 설정하면 필요하면 크기가 조정됩니다. 귀하의 표시 레이아웃은 완전하지 않습니다와 나는 단순히 당신이 뭔가 여기 hardfixed 것으로 의심 : 당신이 모든 FrameLayout 년을 LinearLayoutTextView을 래핑하는 레이아웃과에

android:layout_height="?android:attr/listPreferredItemHeight 

또한 실제 포인트가 없습니다. 당신은 패딩과 BG와 같은 효과가 android:layout_heightwrap_content 대신 "?android:attr/listPreferredItemHeight"을 설정 FrameLayout

+0

죄송합니다. 정확히 "wrap_content"로 설정해야하는 것이 무엇인지 이해하지 못합니까? –

0

시도로 이동할 수 있습니다. 이 같은

뭔가 :

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
+0

아니요 작동하지 않습니다. 나는 여전히 같은 문제에 직면 해있다. –

+0

다른 방법으로이 문제를 해결할 수 있습니까? –

관련 문제