This problem seem simple but I can not solve this problem now.
I have ListView in ScrollView (I know do not do this)
Now, with ListView in ScrollView I using custom view ExpandableHeightListView (how to make multiplelistview in Scrollview?) to show all item.
This is my scrollView
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:orientation="vertical"
android:id="@+id/layoutHero">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="ANTI-MAGE"
android:id="@+id/txtName"
android:gravity="center_horizontal"
android:textSize="30sp"
android:textStyle="bold"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/item_weapons"
android:id="@+id/imageHero"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Carry - Nuker - Melee - Escape"
android:gravity="center_horizontal"
android:id="@+id/txtRoles"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/layoutHero"
android:id="@+id/layoutBio"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/material_blue_grey_800"></LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="BIO"
android:clickable="true"
android:id="@+id/bioTextView"
android:layout_marginTop="5dp"
android:textSize="20dp"
android:gravity="center_horizontal"
android:textColor="#793838"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:layout_height="wrap_content"
android:id="@+id/txtBio"
android:text="The monks of Turstarkuri watched kahfksajfhskald"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/layoutBio"
android:id="@+id/skillLayout"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/material_blue_grey_800"></LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="OVERVIEW"
android:layout_marginTop="5dp"
android:id="@+id/overviewLayout"
android:textSize="20dp"
android:gravity="center_horizontal"
android:textColor="#793838"
android:textStyle="bold"/>
<com.dotalibrary.ExpandableHeightListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lstSkill"
android:fadingEdge="none"
android:focusable="false"
android:scrollbars="none"
android:nestedScrollingEnabled="true"
>
</com.dotalibrary.ExpandableHeightListView>
</LinearLayout>
</RelativeLayout>
This is item of listView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layoutLeft" android:orientation="horizontal">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:paddingTop="10dp"
android:src="@mipmap/ic_launcher"
android:id="@+id/imageAbility"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mana Break"
android:layout_toLeftOf="@id/imageAbility"
android:id="@+id/txtAbility"
android:textSize="18sp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:id="@+id/txtDetail"
android:text="akjdfhakdfjhakdfjhadfkjhadkfjakdjfhadksjfhdakfjhadkfadfkjhadklfhafkldahfkasfh"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="NOTE: blah blahsalkfdjdlkj"
android:id="@+id/txtAbilityNote"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtAffect"
android:text="A modified technique of the Turstarkuri monks"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtAttribs"
android:text="A modified technique of the Turstarkuri monks"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtDamage"
android:text="A modified technique of the Turstarkuri monks"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtCmb"
android:text="A modified technique of the Turstarkuri monks"/>
</LinearLayout>
This is custom class implement ListView
public class ExpandableHeightListView extends ListView{
boolean expanded = false;
public ExpandableHeightListView(Context context)
{
super(context);
}
public ExpandableHeightListView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public ExpandableHeightListView(Context context, AttributeSet attrs,int defStyle)
{
super(context, attrs, defStyle);
}
public boolean isExpanded()
{
return expanded;
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
// HACK! TAKE THAT ANDROID!
if (isExpanded())
{
// Calculate entire height by providing a very large height hint.
// But do not use the highest 2 bits of this integer; those are
// reserved for the MeasureSpec mode.
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
else
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
public void setExpanded(boolean expanded)
{
this.expanded = expanded;
}
}
Now, when I set data to ListView through Adapter. ListView do not show all item i had set. Example: I set 4 item, it only show 3 or 3.5 item
Who can give me advise about it ?
Thank you.