Collapsing Toolbar With Listview
When I collapse Toolbar, ListView appearance is half.It just looks like square. However, I want to see all of them. It should extend downward. ListView might have a problem. How ca
Solution 1:
You can fix it when you add attribute android:fillViewport="true" in android.support.v4.widget.NestedScrollView
This is my code:
<android.support.v4.widget.NestedScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:fillViewport="true"app:layout_behavior="@string/appbar_scrolling_view_behavior"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><ListViewandroid:id="@+id/titlesListView"android:layout_width="match_parent"android:layout_height="match_parent"android:padding="16dp" />
</LinearLayout >
</android.support.v4.widget.NestedScrollView>
It works like a magic.
Solution 2:
You can do like this.
add
CustomListView
publicclassCustomListViewextendsListView { publicCustomListView(Context context) { super(context); } publicCustomListView(Context context, AttributeSet attrs) { super(context, attrs); } publicCustomListView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @TargetApi(Build.VERSION_CODES.LOLLIPOP)publicCustomListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @OverrideprotectedvoidonMeasure(int widthMeasureSpec, int heightMeasureSpec) { intexpandSpec= MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2 , MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }
change xml code
You change this.
<ListView
android:id="@+id/lstTask"
android:layout_width="match_parent"
android:layout_height="287dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="12dp"/>
To
<!-- your package name--><com.your.app.utils.CustomListViewandroid:id="@+id/lstTask"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentStart="true"android:layout_alignParentTop="true"android:layout_marginTop="12dp"/>
Post a Comment for "Collapsing Toolbar With Listview"