横屏展示 fragment 监听面积并非全屏,部分面积监听失效

具体效果如下:

将这个textview 向左移动,那么都可以监听,如上图。如果控件向右移,只有第一个textview 刚刚出头的部分可以监听,如下图

貌似监听宽度还只是竖屏!?

原因:在fragment所在的 activity 布局中添加了 DrawerLayout, DrawerLayout是隐藏的,但是焦点区域覆盖了:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".childmenu.RealTimeDataActivity">

    <FrameLayout
        android:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="51dp"/>

    <include layout="@layout/app_bar" />
</RelativeLayout>

app_bar.xml:

<?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"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/title"
        android:layout_width="fill_parent"
        android:layout_height="48dp"
        android:background="@color/colorBase" >

        <ImageView android:id="@+id/menu_back"
        android:layout_width="35dp"
        android:layout_height="28dp"
        android:layout_marginLeft="5dp"
        android:layout_centerVertical="true"
        android:src="@drawable/menu_back"/>

        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:id = "@+id/titleBar"
            android:text="间隔#1"
            android:layout_marginLeft="45dp"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"
            android:textSize="14sp"/>

        <ImageView android:id="@+id/menu_btn"
        android:layout_marginTop="1dp"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:paddingRight="5dp"
        android:layout_alignParentRight="true"
        android:layout_centerInParent="true"
        android:src="@drawable/menu_slide"/>

    </RelativeLayout>

    <androidx.drawerlayout.widget.DrawerLayout
        android:id="@+id/drawer"
        android:layout_width="220dp"
        android:layout_height="match_parent"
        android:layout_gravity="right">
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_gravity="right">

            <ListView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/slide_menu"/>
        </LinearLayout>
    </androidx.drawerlayout.widget.DrawerLayout>
</LinearLayout>

使用DrawerLayout一定注意焦点覆盖的问题!!!

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值