dev*_*oid 2 android touch relativelayout android-linearlayout
我有这样的布局.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
....>
<LinearLayout
android:id="@+id/box1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
...............
..............
</LinearLayout>
<LinearLayout
android:id="@+id/box2"
android:background="#c0000000"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
.............
.............
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Box2显示在Box1上方,由于Box2的半透明颜色,Box1部分可见.现在我想通过box2消耗掉所有的触摸事件,这样Box2中的Buttons和EditTexts就不起作用了.如何通过java代码完成?
你在布局上设置了触摸监听器,如:
your_liner_layout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event){
return true;
}
});
Run Code Online (Sandbox Code Playgroud)
这将消耗事件并阻止事件的传播
| 归档时间: |
|
| 查看次数: |
5196 次 |
| 最近记录: |