Android Question A simple button

Discussion in 'Android Questions' started by LucaMs, Jan 23, 2015.

  1. LucaMs

    LucaMs Expert Licensed User

    A simple button added by code certanly has its default properties.

    What is its default color? More exactly, what type is it. [P.S.: StateListDrawable]

    If I add a button this way and then I reset its color, it appears higher.

    Is this due to the padding? Or to the corner radius?
     

    Attached Files:

    Last edited: Jan 24, 2015
  2. LucaMs

    LucaMs Expert Licensed User

  3. LucaMs

    LucaMs Expert Licensed User

    I am really surprised.

    Has no one ever allowed the user to save the color of a button in the preferences?

    Probably for the button images are most used.

    Certainly it is strange that no one has noticed this problem before.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Buttons are made of nine patch images. When you set the Button's Color property you remove the existing background and set a new ColorDrawable. Unlike the image which has some padding the ColorDrawable doesn't have any padding.
     
  5. LucaMs

    LucaMs Expert Licensed User


    I think you agree that you expected a different behavior, which is the same that is obtained using the Designer.

    So should I get nine patch image and restore it? Or worse, get it and then recolor it!

    Maybe you can make this change in the next version of B4A.



    Thanks, Erel
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    It is not really related to B4A. This is how Android works. Changing the color with the designer will also remove the nice images.
     
  7. LucaMs

    LucaMs Expert Licensed User

    Ok, understood :)

    Thank you
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice