quemb / QMBForm

Create simple Android forms
MIT License
180 stars 43 forks source link

Android TextAppearances and Colors #24

Closed hiworld75018 closed 8 years ago

hiworld75018 commented 8 years ago

Hi, I made some changes to use default android TextAppearance, or apply specific TextAppearances and Colors to cells. Here are the changes I made:

Upgrade build tools to 1.5.0 Upgrade compileSdkVersion and targetSdkVersion to 23, appcompat-v7 to 23.0.3 Use of AppCompatActivity Choice of 2 available app themes ("AppTheme.Light" and "AppTheme") to use in Manifest Translucent separator background: drawable/section_seperator_background.xml. No divider for the last cell in section (RowDescriptor.mLastRowInSection added) - if separator is enabled. By default, cells adopt default title (TextView) or edit (EditText) styling defined in app theme. TextAppearance and colors can be set using custom TextAppearance styles (in styles.xml) and custom colors:

HashMap<String, Object> cellConfig = new HashMap<>(8); // TextAppearance for section, label, value and button cellConfig.put(CellDescriptor.APPEARANCE_SECTION, Integer.valueOf(R.style.TextAppearance_Form_Section)); cellConfig.put(CellDescriptor.APPEARANCE_TEXT_LABEL, Integer.valueOf(R.style.TextAppearance_Form_Label)); cellConfig.put(CellDescriptor.APPEARANCE_TEXT_VALUE, Integer.valueOf(R.style.TextAppearance_Form_Value)); cellConfig.put(CellDescriptor.APPEARANCE_BUTTON, Integer.valueOf(R.style.TextAppearance_Form_Button)); // Color for label and value cellConfig.put(CellDescriptor.COLOR_LABEL, Integer.valueOf(0x80C0FFC0)); cellConfig.put(CellDescriptor.COLOR_VALUE, Integer.valueOf(0xC0C0FFC0)); // Disabled color for label and value cellConfig.put(CellDescriptor.COLOR_LABEL_DISABLED, Integer.valueOf(0x80FFC0C0)); cellConfig.put(CellDescriptor.COLOR_VALUE_DISABLED, Integer.valueOf(0xC0FFC0C0)); formDescriptor.setCellConfig(cellConfig);

Note that colors can be defined as android attributes and "extracted" when setting CellDescriptor. Examples are included in SampleAnnotationFormFragment, SampleMultivalueSectionFormFragment and SampleFormFragment.

Please comment.

tonimoeckel commented 8 years ago

Thanks!

hiworld75018 commented 8 years ago

Sorry about the compilation errors in those... I'm sending you another PR as complement to the changes I made.