Java Listview没有垂直滚动?
我有一个父片段,它持有视图寻呼机 在视图寻呼机中有两个片段称为1stFragVP和2ndFragVP 在1stFragVP的布局中,我有Listview 视图寻呼机能够水平滚动,但listview垂直滚动未发生 父片段XMLJava Listview没有垂直滚动?,java,android,listview,Java,Android,Listview,我有一个父片段,它持有视图寻呼机 在视图寻呼机中有两个片段称为1stFragVP和2ndFragVP 在1stFragVP的布局中,我有Listview 视图寻呼机能够水平滚动,但listview垂直滚动未发生 父片段XML <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" a
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/parent_ll"
android:layout_marginTop="15dp"
android:layout_weight="5">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="45dp">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="@style/CustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#f1f1f2"
app:elevation="0dp"
app:tabGravity="fill"
app:tabIndicatorColor="@color/orange"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
第一个fragvpxml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:divider="#ebf2f2"
android:dividerHeight="0dp"/>
<RelativeLayout
android:id="@+id/no_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:layout_centerInParent="true"
android:visibility="gone">
<TextView
android:id="@+id/no_item_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/medium_font" />
</RelativeLayout>
</RelativeLayout>
尝试以下代码:
yourlistView.setOnTouchListener(new ListView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
v.onTouchEvent(event);
return true;
}
});
它将禁用父视图触摸管理,并将事件传递到您的
listview
post代码xml java文件etc@Ahamed请再次检查问题。我正在尝试此代码,但未获得事件。我怎样才能得到它呢?触摸事件附在你的listview上。你有其他的布局吗