Java Android Layout元件點擊穿透 click through

  • 6030
  • 0

摘要:Java Android Layout元件點擊穿透 click through

點擊的layout後面要是有按鈕元件的話

就會穿透點到後面的按鈕

這時候就設定layout的touch監聽,回傳true

就可以防止穿透了


//點擊不穿透
LinearLayout llabout = (LinearLayout)findViewById(R.id.ll_about);//先指定你要處理的layout
llabout.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
       return true;
    }
});