new button style for default theme

This commit is contained in:
Vadim Lopatin 2015-01-14 09:56:11 +03:00
parent ef4d842d38
commit 05165a5b18
10 changed files with 43 additions and 7 deletions

18
res/btn_background.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/btn_pressed" />
<item android:state_focused="true" android:state_default="true" android:state_enabled="true"
android:drawable="@drawable/btn_default" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/btn_normal" />
<item android:state_enabled="true" android:state_default="true"
android:drawable="@drawable/btn_default" />
<item android:state_enabled="true" android:state_hovered="true"
android:drawable="@drawable/btn_hover" />
<item android:state_enabled="true"
android:drawable="@drawable/btn_normal" />
<item
android:drawable="@drawable/btn_disabled" />
</selector>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="btn_disabled"
android:state_enabled="false"/>
<item
android:drawable="@null"
android:state_focused="true" />
<item
android:drawable="btn_pressed"
android:state_pressed="true" />
<item
android:drawable="btn_hover"
android:state_hovered="true" />
<item
android:drawable="@null" />
</selector>

BIN
res/mdpi/btn_default.9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

BIN
res/mdpi/btn_disabled.9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

BIN
res/mdpi/btn_hover.9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

BIN
res/mdpi/btn_normal.9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

BIN
res/mdpi/btn_pressed.9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<theme id="theme_default" fontSize="15" >
<style id="BUTTON"
backgroundImageId="btn_default_small"
backgroundImageId="btn_background"
align="Center"
margins="5,5,5,5"
/>
<style id="BUTTON_TRANSPARENT"
backgroundImageId="btn_default_small_transparent"
backgroundImageId="btn_background_transparent"
align="Center"
/>
<style id="BUTTON_LABEL"
@ -31,7 +31,7 @@
minHeight="5"
/>
<style id="BUTTON_NOMARGINS"
backgroundImageId="btn_default_small"
backgroundImageId="btn_background"
align="Center"
/>
<drawable id="scrollbar_button_up" value="scrollbar_btn_up"/>

View File

@ -348,6 +348,7 @@ void extractStateFlag(ref string[string] attr, string attrName, string attrName2
void extractStateFlags(ref string[string] attr, ref uint stateMask, ref uint stateValue) {
extractStateFlag(attr, "state_pressed", "android:state_pressed", State.Pressed, stateMask, stateValue);
extractStateFlag(attr, "state_focused", "android:state_focused", State.Focused, stateMask, stateValue);
extractStateFlag(attr, "state_default", "android:state_default", State.Default, stateMask, stateValue);
extractStateFlag(attr, "state_hovered", "android:state_hovered", State.Hovered, stateMask, stateValue);
extractStateFlag(attr, "state_selected", "android:state_selected", State.Selected, stateMask, stateValue);
extractStateFlag(attr, "state_checkable", "android:state_checkable", State.Checkable, stateMask, stateValue);

View File

@ -749,14 +749,14 @@ Theme createDefaultTheme() {
}
//res.fontFace = "Arial Narrow";
res.fontSize = 15; // TODO: choose based on DPI
Style button = res.createSubstyle("BUTTON").backgroundImageId("btn_default_small").alignment(Align.Center).setMargins(5,5,5,5);
res.createSubstyle("BUTTON_TRANSPARENT").backgroundImageId("btn_default_small_transparent").alignment(Align.Center);
Style button = res.createSubstyle("BUTTON").backgroundImageId("btn_background").alignment(Align.Center).setMargins(5,5,5,5);
res.createSubstyle("BUTTON_TRANSPARENT").backgroundImageId("btn_background_transparent").alignment(Align.Center);
res.createSubstyle("BUTTON_LABEL").layoutWidth(FILL_PARENT).alignment(Align.Left|Align.VCenter);
res.createSubstyle("BUTTON_ICON").alignment(Align.Center);
res.createSubstyle("TEXT").setMargins(2,2,2,2).setPadding(1,1,1,1);
res.createSubstyle("HSPACER").layoutWidth(FILL_PARENT).minWidth(5).layoutWeight(100);
res.createSubstyle("VSPACER").layoutHeight(FILL_PARENT).minHeight(5).layoutWeight(100);
res.createSubstyle("BUTTON_NOMARGINS").backgroundImageId("btn_default_small").alignment(Align.Center); // .setMargins(5,5,5,5)
res.createSubstyle("BUTTON_NOMARGINS").backgroundImageId("btn_background").alignment(Align.Center); // .setMargins(5,5,5,5)
//button.createState(State.Enabled | State.Focused, State.Focused).backgroundImageId("btn_default_small_normal_disable_focused");
//button.createState(State.Enabled, 0).backgroundImageId("btn_default_small_normal_disable");
//button.createState(State.Pressed, State.Pressed).backgroundImageId("btn_default_small_pressed");
@ -1015,7 +1015,7 @@ bool loadStyleAttributes(Style style, Element elem, bool allowStates) {
* <?xml version="1.0" encoding="utf-8"?>
* <theme id="theme_custom" parent="theme_default">
* <style id="BUTTON"
* backgroundImageId="btn_default_small"
* backgroundImageId="btn_background"
* >
* </style>
* </theme>