Я умышленно пошел против гайдлайнов и паттернов гугла и поместил ExpandableListView внутрь ScrollView.
В ExpandableListView 12 групп по одному элементу (TextView) в каждой группе (выпадающем списке).
Хочу получить высоту дочернего элемента во время раскрытия группы ( public void onGroupExpand(int i) { } ), что бы затем при раскрытии увеличить высоту ExpandableListView на высоту дочернего элемента, иначе выпадающий список не скролится (т.к. срабатывает скролл от ScrollView )
Код: Выделить всё
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/preparati_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/name"
android:textColor="@color/text_title"
android:textSize="20sp">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/description"
/>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:src="@drawable/char" />
<TextView
android:id="@+id/tv_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_color" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/producer"
android:textColor="@color/text_title" />
<TextView
android:id="@+id/tv_producer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_color" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/group"
android:textColor="@color/text_title" />
<TextView
android:id="@+id/tv_group"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/release_form"
android:textColor="@color/text_title" />
<TextView
android:id="@+id/tv_release_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_color" />
<ExpandableListView
android:id="@+id/expandableListView"
android:layout_width="match_parent"
android:layout_height="700dp"
android:groupIndicator="@drawable/indicator" />
</LinearLayout>
</ScrollView>
Код: Выделить всё
TextView childItem = (TextView) mExpandableListView
.getExpandableListAdapter().getChildView(i, 0, false, null, mExpandableListView);
Log.d(LOG_TAG, "view " + childItem.getClass().toString() +
" hight " + childItem.getHight() +
" Measuredhight " + childItem.getMeasuredHeight() +
" LayoutParams.hight " + childItem.getLayoutParams().height );
Код: Выделить всё
Height 0
MeasuredHeight 0
LayoutParams.height -2
На стаковерфлоу рекомендуют расширить класс TextView и переопределить метод, в котором высчитать количество строк. Может есть более простой способ?
Этот весь велосипед пришлось изобретать т.к. не нашел в андроиде стандартных спойлеров ( напр. HTML текст под спойлером)
P.S.