Invisible / transparent button that works like a regular in android?

≡放荡痞女 提交于 2019-11-30 06:20:57

Here you go:

Button theButton = (Button)findViewById(R.id.theButton);
theButton.setVisibility(View.VISIBLE);
theButton.setBackgroundColor(Color.TRANSPARENT);

phoneButton.setOnClickListener(new OnClickListener()
{   
    @Override
    public void onClick(View v)
    {
        // DO STUFF
    }
});
android:background="@android:color/transparent"

You can try set transparent background to the button. But do not change buttons visibility, cause that prevents view from getting click events.

You can also use

android:background = "@null"

There's:

android:background="?android:attr/selectableItemBackground"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!