0

I have 3 buttons, which needs to have white background and radius of 20

My GradientDrawable function

private GradientDrawable imageButtonGradient() {
        GradientDrawable buttonShape = new GradientDrawable();
        buttonShape.setCornerRadius(20);
        buttonShape.setColor(Color.WHITE);
        return buttonShape;
    }

i use call the function and set the background

GradientDrawable buttonGradient = imageButtonGradient(); captureImageButton.setBackground(buttonGradient);

I can see it capture button as i need it

works as required

However when i use the gradient for Back and submit button

doesn't work

I am using the same function for GradientDrawable. Using the same way to call the function. I am using it as following

captureImageButton.setBackground(buttonGradient);
backButton.setBackground(buttonGradient);
submitButton.setBackground(buttonGradient);

As shown, the back button and submit button have been both rounded. So it is working, however i am just not sure why the captureImageButton is not showing full white color as it should.

Any suggestions?

4

1 回答 1

0

Found solution for this,

for some odd reason i have to call GradientDrawable function twice, once for the back and submit button and once for capture button.

GradientDrawable buttonGradient = imageButtonGradient();
GradientDrawable captureButtonGradient = imageButtonGradient();

and than set the background as following

captureImageButton.setBackground(captureButtonGradient);
backButton.setBackground(buttonGradient);
submitButton.setBackground(buttonGradient);

Thanks anyways.

于 2017-03-12T23:32:46.927 回答