Android Question Theme changing borders

advansis

Active Member
Licensed User
Longtime User
Hi to everybody,
I would like to modify my theme (I'm using AppCompat themes).
I'm already able to change colors and paddings with "CreateResource/style" in Manifest editor.
Now I need to change background of my editext-views such as they will have round borders.
Is it possible throught Manifest editor ? Thanks in advance.
 

Semen Matusovskiy

Well-Known Member
Licensed User
Imagine that you manifest looks so:

B4X:
SetApplicationAttribute (android:theme, "@style/MyAppTheme")
CreateResource (values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.NoActionBar"> ...  </style>
</resources>
)

Do following:
1) Create own oval shape

B4X:
CreateResource (drawable, myshape.xml, <shape ...></shape>)

2) In theme.xml add your custom style
B4X:
    <style name="App_EditTextStyle" parent="Widget.AppCompat.EditText">
        <item name="android:background">@drawable/myshape</item>
        ...
    </style>

3) Inside <style name="MyAppTheme" ...></style> add reference
B4X:
        <item name="editTextStyle">@style/App_EditTextStyle</item>
 

Attachments

  • test.zip
    7.7 KB · Views: 199
Last edited:
Upvote 0

advansis

Active Member
Licensed User
Longtime User
Thank you very much. Works correctly!
Any clue for using it with spinners ?
I used the "spinnerStyle" attribute, but now I cannot see the selection arrow anymore.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Spinners have more complex style. it's possible to "correct" also (using, for example, information from https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v7/appcompat ).
But, I think, to correct styles for all EditText/Spinners and etc. is a wrong way. First of all, because users expect classic view.

I can imagine that you want to highlight some fields, for example, using oval border.
Personally I would use another approach. I would place edittext/spinner on transparent panel. For panel I would set selector with shapes.
 
Upvote 0

advansis

Active Member
Licensed User
Longtime User
You are right, I would like to highlight some fields for error handling in user forms.
If I change the color for a wrong value of a spinner, the arrow disappears...
Instead of using other panels, I'll try to draw directly on the activity/panel canvas containing the views... (by surrounding each view with a rectangle, for example)
Thanks a lot!
 
Upvote 0
Top