在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Android/ 安卓布局如何讓 listview 和listview上的布局一起滾動(dòng)

安卓布局如何讓 listview 和listview上的布局一起滾動(dòng)

xml布局如下 但是不能實(shí)現(xiàn)我說(shuō)的listview 和上面布局一起滾動(dòng)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">
    <include layout="@layout/top" />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:background="#fff">
                <com.jude.rollviewpager.RollPagerView
                    android:id="@+id/roll_view_pager"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    app:rollviewpager_play_delay="3000"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="170dp"
                android:background="#fff"
                android:orientation="vertical"
                android:layout_marginBottom="10dp">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="85dp"
                    android:background="#fff"
                    android:orientation="horizontal">
                    <LinearLayout
                        android:id="@+id/home_menu_cyms"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:background="@drawable/me_selecter"
                        android:orientation="vertical">
                        <ImageView
                            android:layout_width="35dp"
                            android:layout_height="35dp"
                            android:layout_gravity="center"
                            android:layout_marginTop="15dp"
                            android:src="@drawable/cyms"/>
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:gravity="center"
                            android:layout_weight="1"
                            android:textSize="13dp"
                            android:text="餐飲美食"/>
                    </LinearLayout>
                    <LinearLayout
                        android:id="@+id/home_menu_xxyl"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:background="@drawable/me_selecter"
                        android:orientation="vertical">
                        <ImageView
                            android:layout_width="35dp"
                            android:layout_height="35dp"
                            android:layout_gravity="center"
                            android:layout_marginTop="15dp"
                            android:src="@drawable/ylxx"/>
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:textSize="13dp"
                            android:text="休閑娛樂(lè)"/>
                    </LinearLayout>
                    <LinearLayout
                        android:id="@+id/home_menu_jdzs"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:background="@drawable/me_selecter"
                        android:orientation="vertical">
                        <ImageView
                            android:layout_width="35dp"
                            android:layout_height="35dp"
                            android:layout_gravity="center"
                            android:layout_marginTop="15dp"
                            android:src="@drawable/jdzs"/>
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:textSize="13dp"
                            android:text="酒店住宿"/>
                    </LinearLayout>
                    <LinearLayout
                        android:id="@+id/home_menu_qcfw"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:background="@drawable/me_selecter"

                        android:orientation="vertical">
                        <ImageView
                            android:layout_width="35dp"
                            android:layout_height="35dp"
                            android:layout_gravity="center"
                            android:layout_marginTop="15dp"
                            android:src="@drawable/qcfw"/>
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:textSize="13dp"
                            android:text="汽車服務(wù)"/>
                    </LinearLayout>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="85dp"
                    android:background="#fff"

                    android:orientation="horizontal">
                    <LinearLayout
                        android:id="@+id/home_menu_lrmy"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:background="@drawable/me_selecter"
                        android:orientation="vertical">
                        <ImageView
                            android:layout_width="35dp"
                            android:layout_height="35dp"
                            android:layout_gravity="center"
                            android:layout_marginTop="10dp"
                            android:src="@drawable/lrmy"/>
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:gravity="center"
                            android:layout_weight="1"
                            android:textSize="13dp"
                            android:text="麗人美業(yè)"/>
                    </LinearLayout>
                    <LinearLayout
                        android:id="@+id/home_menu_smfw"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:background="@drawable/me_selecter"
                        android:orientation="vertical">
                        <ImageView
                            android:layout_width="35dp"
                            android:layout_height="35dp"
                            android:layout_gravity="center"
                            android:layout_marginTop="10dp"
                            android:src="@drawable/shgw"/>
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:textSize="13dp"
                            android:text="生活服務(wù)"/>
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:layout_marginTop="20dp"
                        android:orientation="vertical">
                        <ImageView
                            android:layout_width="30dp"
                            android:layout_height="30dp"
                            android:layout_gravity="center"
                            />
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:text=""/>
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:layout_marginTop="20dp"
                        android:orientation="vertical">
                        <ImageView
                            android:layout_width="30dp"
                            android:layout_height="30dp"
                            android:layout_gravity="center"
                            />
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:text=""/>
                    </LinearLayout>

                </LinearLayout>
            </LinearLayout>
            <ListView
                android:id="@+id/home_list_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:dividerHeight="0.7dp"
                android:divider="#f5f5f5">
            </ListView>
        </LinearLayout>
    </ScrollView>




</LinearLayout>
回答
編輯回答
懶豬
  1. 把上面的view設(shè)置為listview的header,listView.addHeader()方法
  2. scrollView嵌套listview,然后處理滑動(dòng)沖突http://blog.csdn.net/Mannver/...
2018年1月24日 11:03
編輯回答
魚(yú)梓

itemType布局,就用一個(gè)listview去搞

2017年4月9日 00:00
編輯回答
刮刮樂(lè)

如果可以接受把listview換成recyclerview實(shí)現(xiàn)的話,其實(shí)是有個(gè)非常方便的方法
1.將scrollview改成nestedscrollview
2.recyclerview.setNestedScrollEnabled(false)

2017年6月15日 16:39
編輯回答
笑浮塵

把listview和上邊的布局放到一個(gè)布局里,不過(guò)別用ScrollView,用NestScrollView

2017年3月28日 00:45
編輯回答
糖果果

滑動(dòng)監(jiān)聽(tīng)調(diào)用滾動(dòng)的代碼

2017年4月1日 17:22
編輯回答
她愚我

用listview調(diào)用下面的方法,讓listview完全展開(kāi)
public class ListViewUtil {

/**
 * 重新計(jì)算listview的高度
 *
 * @param listView
 */
public static void setListViewHeightBasedOnChildren(ListView listView) {
    if (listView == null)
        return;
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter == null) {
        return;
    }
    int totalHeight = 0;
    for (int i = 0; i < listAdapter.getCount(); i++) {
        View listItem = listAdapter.getView(i, null, listView);
        listItem.measure(0, 0);
        totalHeight += listItem.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = totalHeight
            + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
    listView.setLayoutParams(params);
}

}

2018年2月15日 16:27
編輯回答
夕顏

解決問(wèn)題的方法有很多,除了樓上各層朋友的方法,我也說(shuō)一種:將ScrollView換成RecyclerView,第一個(gè)LIstView是第一個(gè)item,的二個(gè)ListView是第二個(gè)item,然后就完了,沒(méi)有滑動(dòng)沖突。

2017年10月23日 12:04