FrameLayout停止调用ViewPager.OnTouchListener ..为什么?

时间:2018-06-13 11:30:19

标签: android android-viewpager

当我有以下布局时,我的import pygame import serial import time ser = serial.Serial('/dev/ttyACM0', 9600) pygame.mixer.pre_init(channels=6, buffer=1024) pygame.mixer.init() guit_let = ["e", "a"] guitar_notes = [pygame.mixer.Sound("notes/" + letter + ".wav") for letter in guit_let] def guitar(i): guitar_notes[i].play() while True: if ser.in_waiting > 0: line = ser.readline().strip() value = str(line.decode('utf-8')) #value = str(line.decode('ascii')) #a = int(value) if value == '0': guitar(0) print(value) else: guitar(1) print(value) 的{​​{1}}永远不会被调用:

OnTouchListener

以及我的活动中的以下代码:

ViewPager

如果删除<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.constraint.ConstraintLayout xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false" android:clipToPadding="false" tools:context=".MainActivity"> <android.support.v4.view.ViewPager android:id="@+id/vpPages" android:layout_width="match_parent" android:layout_height="wrap_content" /> </android.support.constraint.ConstraintLayout> <!-- If I remove this, everything is fine --> <FrameLayout android:id="@+id/navDrawerRoot" android:layout_width="220dp" android:layout_height="match_parent" android:layout_gravity="start" android:baselineAligned="false" android:fitsSystemWindows="false" android:visibility="gone"/> </android.support.v4.widget.DrawerLayout> ,则会按预期调用override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) vpPages.setOnTouchListener { v, event -> Log.e("TAG", "Touched") false } } 。有谁能解释为什么?我可以对FrameLayout做些什么,以免它干扰OnTouchListener的触摸?

0 个答案:

没有答案