Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27838

Android: Style default tableViewSection headerTitle using XML

    Details

    • Story Points:
      5
    • Sprint:
      2020 Sprint 14, 2020 Sprint 15, 2020 Sprint 16, 2020 Sprint 17, 2020 Sprint 18, 2020 Sprint 19, 2020 Sprint 20, 2020 Sprint 21, 2020 Sprint 22, 2020 Sprint 23

      Description

      If you use the normal table headerTitle you have no option to style the text or create a headerView. This PR gives you at least the option to set a background/font color, border and text style using XML ressource files.

      var win = Ti.UI.createWindow({
      	backgroundColor: "#fff"
      });
       
      var sectionFruit = Ti.UI.createTableViewSection({
      	headerTitle: 'Fruit'
      });
      sectionFruit.add(Ti.UI.createTableViewRow({
      	title: 'Apples',
      	color: "#000"
      }));
      sectionFruit.add(Ti.UI.createTableViewRow({
      	title: 'Bananas',
      	color: "#000"
      }));
       
      var sectionVeg = Ti.UI.createTableViewSection({
      	headerTitle: 'Vegetables'
      });
      sectionVeg.add(Ti.UI.createTableViewRow({
      	title: 'Carrots',
      	color: "#000"
      }));
      sectionVeg.add(Ti.UI.createTableViewRow({
      	title: 'Potatoes',
      	color: "#000"
      }));
       
      var table = Ti.UI.createTableView({
      	data: [sectionFruit, sectionVeg]
      });
       
      win.add(table);
      win.open();
       
      var sectionFish = Ti.UI.createTableViewSection({
      	headerTitle: 'Fish'
      });
      sectionFish.add(Ti.UI.createTableViewRow({
      	title: 'Cod',
      	color: "#000"
      }));
      sectionFish.add(Ti.UI.createTableViewRow({
      	title: 'Haddock',
      	color: "#000"
      }));
       
      table.insertSectionBefore(0, sectionFish);
      

      app/platform/android/res/values/colors.xml

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
          <color name="headerTitleColor">#ff000000</color>
      </resources>
      

      app/platform/android/res/values/dimens.xml

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
         <dimen name="headerTitleSize">16sp</dimen>
      </resources>
      

      app/platform/android/res/values/strings.xml

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
         <string name="headerTitleStyle">bold</string>
      </resources>
      

      app/platform/android/res/drawable/titantium_ui_header_title_background.xml

      <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
      	<item>
      		<shape android:shape="rectangle">
      			<!-- Bottom Border -->
      			<solid android:color="#33000000"/>
      		</shape>
      	</item>
      	<item android:bottom="1dp">
      		<shape android:shape="rectangle">
      			<solid android:color="#ffff"/>
      		</shape>
      	</item>
      </layer-list>
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                michael Michael Gangolf
                Reviewer:
                Joshua Quick
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration