質問

I want add a effect to on my buttons on android that includes light or only ı may add a light too in this context ı want to ask how to set a backround light to a button on android ?

役に立ちましたか?

解決

For changing the background of a button

  1. design your background in a picture or download the picture that you want to place it for the background.

  2. Place the image in the res/drawable(make sure the name of file contains lower case only)

  3. Goto xml file of the button and write android:background="@drawable/FILENAME replace FILENAME by the name of the picture placed in drawable.

I hope this changes the background of the button.

他のヒント

Simply change the background color of the button on the click event. If you want to change the button programmatically then you can set up an onClick listener or in your xml (XML is usually easier). I also sometimes simply hide the button to show it was clicked but to also avoid a second click that might cause problems.

Here is an example of a programmatic onClick listener:

Button button.setOnClickListener(new View.OnClickListener() {
  public void onClick(View v) {
    Button oneButton;

    // Set the button clicked to a different color
    v.setBackgroundColor(getResources().getColor(R.color.button_selected));
  }
});
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top