0
두 개의 텍스트 뷰가있는 목록보기가 있는데 그 중 하나는 기본적으로 View.GONE으로 설정되어 있으므로 listview는 최소 크기에 대해 wrap_content를 수행하므로 모든 보조 텍스트 뷰가있는 목록 뷰의 크기는 GONE으로 설정됩니다. 그것들 중 하나를 View.VISIBLE (항목을 클릭 함)로 돌리면 높이는 처음 본 wrap_content에서 계산 한 높이와 동일하게 유지됩니다. 내가 읽은 다른 접근을 시도하지만, 그들 중 누구도 같은 안드로이드 뷰를 rewrap_content하는 방법은 무엇입니까?
mListView.invalidate();
mListView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)mListView.getLayoutParams();
params.height = params.WRAP_CONTENT;
각각을 클릭하면 높이 wrap_content 값을 다시 계산보기를 강제 할 수있는 방법이
으로 내 경우에 일하지?EDIT1가 : -이
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/list_item_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Question?"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="8dp"
android:paddingBottom="4dp"
android:textStyle="bold"/>
<TextView
android:id="@+id/list_item_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Answer!"
android:layout_below="@id/list_item_one"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingBottom="4dp"/>
</RelativeLayout>
글쎄, 난 그냥 가시성 변경 및 여전히 동일한 문제가있는 후에 mListView.requestLayout() 추가하려고 onMeasure 재정의해야합니까? – javanewb
@javanewb ListView 항목 레이아웃의 TextViews 부분입니까? 레이아웃을 보면 도움이 될 것입니다. – Simas
방금 메인 포스트에 레이아웃을 추가했습니다 – javanewb