java - 怎样在不重写子布局的情况下,屏蔽侧滑菜单中的内容布局事件?
伊谢尔伦
伊谢尔伦 2017-04-18 10:54:04
0
1
514

我自己对之前的android自定义viewgroup做一个总结,手写一个控件继承viewgroup,采用scroller类实现一个自定义侧滑菜单。疑惑的是,当侧滑菜单展示时,内容布局应当屏蔽事件,但是目前我只知道通过重写内容布局的onInterceptTouchEvent方法返回true做到,但是我考虑到简易化,能否在只手写一个viewgroup情况下,实现这种需求?

<?xml version="1.0" encoding="utf-8"?>
<com.example.caojiantao1.myapplication.SlidingMenu
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:slide="http://schemas.android.com/apk/res-auto"
    slide:content_alpha="0.5"
    slide:menu_width_rate="0.6"
    slide:scale_rate="0.5"
    slide:sliding_mode="qq">

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#69c"
        android:orientation="horizontal">
        
    </LinearLayout>

    <LinearLayout
        android:id="@+id/menu"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#fc6"
        android:orientation="horizontal">

    </LinearLayout>
</com.example.caojiantao1.myapplication.SlidingMenu>

如果直接重写content布局,在onInterceptTouchEvent down中判断返回true,然后用com.xxx.cotent代替是可行的,但是这样我就觉得约束性太强,最终目的是要只要菜单有滑动,点击内容布局就会隐藏menu。有没有大神提提醒,我也研究过requestDisallowInterceptTouchEvent,貌似这个主要针对子view对父布局的,已经自我钻研好多天了,知道的帮忙看看,谢了~~

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

모든 응답(1)
刘奇

이를 어떻게 구현하는지 정확히 모르기 때문에 이 슬라이딩 이벤트를 어떻게 처리할지 말하기는 어렵지만 다른 방법으로 목표를 달성할 수도 있습니다.
전체 화면을 추가해 보세요. 메뉴 뷰 외부의 클릭 이벤트를 가로채서 처리하는 데 사용하세요.
도움이 되길 바랍니다.

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!