The attached project wraps this Github project (still not sure how it relates to "grandmother"...). Posting the following:
1. B4A project demonstrating BabushkaText
2. B4A library files
3. The Java source code (some open heart surgery applied to the original Github project)
Sample Code:
BabushkaText
Author: Johan Schoeman
Version: 1
1. B4A project demonstrating BabushkaText
2. B4A library files
3. The Java source code (some open heart surgery applied to the original Github project)
Sample Code:
B4X:
#Region Project Attributes
#ApplicationLabel: BabushkaText
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private bbt1 As BabushkaText
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
Dim myTextToDisplay(6) As String = Array As String("The Bryant Park Hotel" & Chr(10), "#6 of 434 ", "in New York City" & Chr(10), "2487 reviews" & Chr(10), "$540", " per night")
Dim mytextcolor(6) As Int = Array As Int(0xff414141, 0xff0081E2, 0xff969696, 0xff969696, 0xffF7B53F, 0xff969696)
Dim myTypeFace(6) As Int = Array As Int(bbt1.TYPEFACE_BOLD, bbt1.TYPEFACE_ITALIC, bbt1.TYPEFACE_BOLD_ITALIC, bbt1.TYPEFACE_NORMAL, bbt1.TYPEFACE_BOLD_ITALIC, bbt1.TYPEFACE_BOLD)
Dim mySuperScript(6) As Boolean = Array As Boolean(True, False, True, False, True, False)
Dim mySubScript(6) As Boolean = Array As Boolean(False, True, False, False, False, True)
Dim myUnderline(6) As Boolean = Array As Boolean(True, False, True, False, True, False)
Dim myStrikeThrough(6) As Boolean = Array As Boolean(True, True, False, False, True, False)
Dim myTextSize(6) As Int = Array As Int(35, 30, 35, 40, 45, 55)
Dim myTextBackColor(6) As Int = Array As Int(Colors.Red, Colors.Transparent, Colors.Green, Colors.Transparent, Colors.Transparent, Colors.Transparent)
bbt1.TextToDisplay = myTextToDisplay
bbt1.TextToDisplayColor = mytextcolor
bbt1.TextTypeface = myTypeFace
bbt1.SuperScript = mySuperScript
bbt1.SubScript = mySubScript
bbt1.TextUnderline = myUnderline
bbt1.TextStrikeThrough = myStrikeThrough
bbt1.TheTextSize = myTextSize
bbt1.TextBackgroundColor = myTextBackColor
bbt1.ShowText
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
BabushkaText
Author: Johan Schoeman
Version: 1
- BabushkaText
Fields:- TYPEFACE_BOLD As Int
- TYPEFACE_BOLD_ITALIC As Int
- TYPEFACE_ITALIC As Int
- TYPEFACE_NORMAL As Int
- ba As BA
- BringToFront
- DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
- Initialize (EventName As String)
- Invalidate
- Invalidate2 (arg0 As Rect)
- Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- IsInitialized As Boolean
- RemoveView
- RequestFocus As Boolean
- SendToBack
- SetBackgroundImage (arg0 As Bitmap)
- SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
- SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
- SetTextColorAnimated (arg0 As Int, arg1 As Int)
- SetTextSizeAnimated (arg0 As Int, arg1 As Float)
- SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
- ShowText
- changeTextColor (textColor As Int)
Change text color of all pieces of textview. - display
Call this method when you're done adding {@link babushkatext.BabushkaText.Piece}s
and want this TextView to display the final, styled version of it's String contents.
You MUST also call this method whenever you make a modification to the text of a Piece that
has already been displayed. - removePiece (location As Int)
Removes the Piece at this specified location. The underlying data structure is a
{@link java.util.List}, so expect the same type of behaviour.
location: the index of the Piece to remove - reset
Resets the styling of this view and sets it's content to an empty String.
- Background As Drawable
- Color As Int [write only]
- Enabled As Boolean
- Gravity As Int
- Height As Int
- Left As Int
- SubScript() As Boolean [write only]
- SuperScript() As Boolean [write only]
- Tag As Object
- Text As String
- TextBackgroundColor() As Int [write only]
- TextColor As Int
- TextSize As Float
- TextStrikeThrough() As Boolean [write only]
- TextToDisplay() As String [write only]
- TextToDisplayColor() As Int [write only]
- TextTypeface() As Int [write only]
- TextUnderline() As Boolean [write only]
- TheTextSize() As Int [write only]
- Top As Int
- Typeface As Typeface
- Visible As Boolean
- Width As Int