user3587182
user3587182

Reputation: 1

Use background as button in Android?

I am making and app for android, and currently on the testing stage. When I use the app, I find that it would be a better experience for the user if he or she would be able to press anywhere on the screen, not just the button? I have text and images on the page, but I want the user to be able to click anywhere. So, I was thinking that the best way to do this would be to make the background a button? currently, I have the background set in Html as follows..

    android:background="@drawable/woodbackground"

Any tips would be appreciated. Thanks!

Upvotes: 0

Views: 33

Answers (2)

Guillaume
Guillaume

Reputation: 144

You just have to add :

layout.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v){
        // Do something
    }
}); 

Upvotes: 1

Ibrahim
Ibrahim

Reputation: 2062

You can assign an OnClickListener event to the main layout element. Just refer to it with it's id.

Upvotes: 2

Related Questions