所以我有一个例子: 当我触摸按钮时,一切正常,但是当我触摸布局时,其子级变得不可触摸。如果我在该布局下还有另一个视图,则会遇到同样的问题:当我触摸按钮时,其布局变得像实心,并且像布局一样阻塞了输入,从而消耗了触摸或变成了焦点idk ...
代码: main.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:clickable="false"
android:id="@+id/mainFrameLayout"
android:background="#55ff0000"
>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:text="below Frame"
android:id="@+id/mainButton1"
/>
<ViewFlipper
android:layout_width="fill_parent"
android:layout_height="200dp"
android:id="@+id/mainViewFlipper2"
android:background="#5500ff00"
android:clickable="false"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:clickable="false"
>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/mainButton2"
android:layout_gravity="center"
/>
</FrameLayout>
</ViewFlipper>
</FrameLayout>
MainActivity.java
package com.mycompany.myapp2;
import android.app.*;
import android.os.*;
import android.view.View.*;
import android.view.*;
import android.widget.*;
import android.widget.ActionMenuView.*;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.mainButton1).setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v,MotionEvent e)
{
return false;
}
});
findViewById(R.id.mainButton2).setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v,MotionEvent e)
{
return false;
}
});
//not helped
/*findViewById(R.id.mainFrameLayout).setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v,MotionEvent e)
{
return false;
}
});*/
//not working either
//findViewById(R.id.mainFrameLayout).setOnTouchListener(null);
}
}
像我想象的那样,我的ViewFlipper具有多个包含复杂UI的FrameLayouts,当我按住1按钮时-ViewFlipper后面的SurfaceView变得不可触摸-那就是我的问题