android布局外点击,android DrawerLayout 点击穿透、点击自身消失等问题解决

66b52468c121889b900d4956032f1009.png

8种机械键盘轴体对比

本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?

问题1:在DrawerLayout内部中点击,DrawerLayout的布局莫名消失。

解决1:DrawerLayout的布局必须放在页面主布局的下面。

To use a DrawerLayout, position your primary content view as the first child with a width and height of match_parent. Add drawers as child views after the main content view and set the layout_gravity appropriately. Drawers commonly use match_parent for height with a fixed width.

问题2:点击DrawerLayout的布局,会触发被滑出页面挡住的布局中的点击事件。

解决2:在DrawerLayout的最外层布局中,设置android:clickable=”true”

问题3: java.lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY.

解决3:设置DrawerLayout的height为 match_parent.

Drawers commonly use match_parent for height with a fixed width.

下面贴上一段代码供大家参考:

android:id="@+id/side_menu"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_below="@+id/widget_main">

android:layout_width="match_parent"

android:layout_height="match_parent"

>

............

主布局代码

............

............

android:id="@+id/side_menu_content"

android:layout_width="match_parent"

android:clickable="true"

android:layout_height="match_parent"

android:layout_gravity="left">

android:id="@+id/rl_side_menu_quit"

android:layout_width="match_parent"

android:layout_height="50dp"

android:layout_alignParentBottom="true"

android:background="@color/title_bg"

android:gravity="bottom">

android:id="@+id/img_quit"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_centerVertical="true"

android:padding="5dp"

android:src="@drawable/quit" />

android:id="@+id/tv_quit"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerInParent="true"

android:layout_toRightOf="@id/img_quit"

android:gravity="center_vertical"

android:text="退出"

android:textColor="@color/white"

android:textSize="18sp" />

谢谢阅读。你们的支持是我坚持的下去的动力。

原创: Vampire hunter

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值