2016-08-26 30 views
1

我試過TouchDelegate,它說這樣做。它可以增加命中區域,但不能減少命中區域。如何縮小/減小android中按鈕的命中區域?

我們可以改變xml文件中的命中區嗎?

我的測試代碼只是從Extend a Child View's Touchable Area複製,其中說,'你也可以使用這種方法來縮小孩子的觸摸區域,如果需要的話'。

+2

顯示你已經嘗試過,所以我們可以看到它爲什麼不起作用 –

+0

我試過使用delegateArea.right - = 100; delegateArea.bottom - = 100; – akiyame

回答

0

在鏈接您提供:

// Extend the touch area of the ImageButton beyond its bounds 
// on the right and bottom. 
delegateArea.right += 100; 
delegateArea.bottom += 100; 

將其更改爲:

delegateArea.right -= 100; 
delegateArea.bottom -= 100; 

現在你會得到期望的結果。您可能需要將值從100更改爲您認爲合適的值。

+0

我這樣做了,但沒有工作!我點擊邊緣,按鈕仍然打開。 – akiyame

相關問題