63ScrollView nested listview problems and how to solve them

Source: Internet
Author: User

Project to use the ScrollView combined with the GridView, there are a lot of problems, here first take the ListView to open brush. The effect you want to achieve is as follows:


But the effect of the implementation is as follows:


It crashed. The layout is like this:

<scrollview xmlns:android= "http://schemas.android.com/apk/res/android"    android:layout_width= "Match_ Parent "    android:layout_height=" match_parent "     >    <listview        android:id=" @+id/list_view "        android:layout_width= "match_parent"        android:layout_height= "wrap_content" >    </ListView> </ScrollView>

Add the following properties to ScrollView:

Android:fillviewport= "true"

Run the interface is out, but the interface is not able to drag, the solution is to customize the ListView:

Package Com.example.uilistviewtest;import Android.content.context;import Android.util.attributeset;import Android.widget.listview;public class Mylistview extends Listview{public Mylistview (context context, AttributeSet attrs , int defstyleattr) {Super (context, attrs, defstyleattr);} Public Mylistview (context context, AttributeSet Attrs) {Super (context, attrs);} Public Mylistview (Context context) {super (context);} @Overrideprotected void onmeasure (int widthmeasurespec, int heightmeasurespec) {int expandspec = Measurespec.makemeasurespec (Integer.max_value >> 2, measurespec.at_most); Super.onmeasure (WidthMeasureSpec, EXPANDSPEC);}}
The new layout:

<scrollview xmlns:android= "http://schemas.android.com/apk/res/android"    android:layout_width= "Match_ Parent "    android:layout_height=" match_parent "     >    <com.example.uilistviewtest.mylistview        Android:id= "@+id/list_view"        android:layout_width= "match_parent"        android:layout_height= "Wrap_content" >    </com.example.uilistviewtest.MyListView></ScrollView>


Run again and solve the problem.

The exchange can add me: 619189810


63ScrollView nested listview problems and how to solve them

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.