Android Code Snippet TabStripViewPager with FontAwesome / Material Icons

upload_2016-12-7_7-41-22.png


Step 1: Add a label named lblFontAwesome with the designer. Set its Typeface to FontAwesome and make it invisible.

Step 2: Use the code editor Icon Picker to add the icons (right click to find it):

B4X:
TabStrip1.LoadLayout("Page1", "iOS " & Chr(0xF179))
TabStrip1.LoadLayout("Page2", "Android " & Chr(0xF17B))
TabStrip1.LoadLayout("Page3", "Windows " & Chr(0xF17A))
TabStrip1.LoadLayout("Page4", "" & Chr(0xF061))

Step 3: Set the typeface of the TabStrip header labels to FontAwesome:
B4X:
For Each lbl As Label In GetAllTabLabels(TabStrip1)
   lbl.Typeface = Typeface.FONTAWESOME
Next

Code for GetAllTabLabels is available here: https://www.b4x.com/android/forum/t...ger-better-viewpager.63975/page-2#post-408977
It depends on JavaObject and Reflection libraries.
 
Last edited:

Angel Garcia

Member
Licensed User
Hi All,
Is there a way to measure the Label Height with fontawesome inside the TabStrip?, this is for adjust TextSize purposes.
I already tried with canvas and su multiline, but i always get a -1, i get correctly the Width after setting it.
I also tried to get the "tabsHeight" object of the tabstrip with no success.
Any ideas?
Thanks in advance!
 
Top