B4A Library DesignSupport - Additional Material Design components

This library is a wrapper to some of the objects of Googles Design Support library.

Requirements:

This library requires B4A 6.31 or above.
From V2.32 on B4A V6.80 or newer is required. If you use an older B4A version use the V2.31 library.
AppCompat 3.30 or above is required.
The examples need some additional libraries like AHViewPager, XMLViewEx, XMLLayoutBuilder

Currently it supports:
  • Snackbar - The new modern toastmessages
    Screenshot_20151001-110844.png
  • TabLayout - The new material like tabs with fixed tabs and scrolling tabs feature. Works standalone or together with a ViewPager library. Supports icons as tabs and custom layouts for the tabs.
    Screenshot_20151001-110749.pngScreenshot_20151001-110809.png
  • FloatlabelEditText - An enhanced EditText object that supports a floating label, counter and error messages.
    Screenshot_20160624-105201.png
  • FloatingActionButton - A very simple Floating Action Button. Has show- and hide animations but is very simple.
    Screenshot_20160624-104708.png
  • NavigationDrawer - Material Design compliant Navigation Drawer. See NavigationView Example for detailed instructions.
    Screenshot_20160826-160906.png
  • BottomNavigationView - Material Design compliant Bottom Navigation View. See BottomNavigationView Example for detailed instructions.
    Screenshot_20161219-091326.png
Installation:
Note: Please, Please read these instructions carefully. AppCompat depends on many things like a special theme with special features. Even special versions of build tools are required and last but not least there are often bugs in the Google support libraries.

I created this instructions to help you getting things ready for using AppCompat. So please follow these instructions carefully and all should work as expected and you don't have to ask in the forum.

Thanks.
  1. This library depends on the AppCompat library. So do all the setup needed for AppCompat.
  2. Copy the DesignSupport.xml, DesignSupport.jar and DesignSupport.aar files to your CustomLibs folder
  3. Install/Update Android Support Packages with the SDK Manager.
Setup and usage:
  1. Setup your project like a project that uses AppCompat library.
If you want to use the DSFloatlabelEditText object with the ErrorText or counter feature you should add the following item to your Theme:
B4X:
<item name="textColorError">@color/design_textinput_error_color_light</item>
Otherwise your app will crash if the textinput reaches the maxCounter length.

If you want to use the DSNavigationDrawer object you should add the following items to your Theme:
B4X:
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>

Your support:
Creating libraries and wrappers for existing library projects is a lot of work. The use of this library is totally free and you even don't need to mention in your app that you use it.
But if you use this library in your projects and you think it is useful to you please consider to make a donation:

Thanks very much for your support.


Version History:

V1.00
  • Initial version with SnackBar and TabLayout objects.
V2.00
  • Requires B4A 6.0 or above
  • Uses new Maven repositories for support libraries
  • Enhanced Designer support (custom properties are supported)
  • New: DSFloatlabelEditText - New EditText with floating label, counter, error messages
  • New: DSFloatingActionButton - Standard Floating Action Button.
V2.10
  • New: Requires Support Repository 36
  • New: DSNavigationDrawer - A complete DrawerLayout implementation/wrapper
  • New: DSNavigationView
  • New: Support for ShowPasswordToggle in FloatLabelEditText
  • Fix: FloatLabelEditText.Enabled=True/False should work now.
V2.20
  • Fix: DSNavigationDrawer should work without a secondary drawer.
  • New: BottomNavigationView - Wrapper for the BottomNavigationView
  • Fix: Some minor fixes and changes
V2.21
  • Fix: DSTablayout can use other ViewPagers than AHViewPager
  • Fix: Small internal bugfixes.
V2.22
  • Fix: Change packagename to anywheresoftware.b4a.orbjects to reduce resouce fields
V2.23
  • Fix: Fix error in FloatLabelEditText
V2.30
  • New: Dismiss event for DSSnackbar
  • New: Support CharSequence where possible
V2.31
  • Fix: Getters return String instead of CharSequence to avoid problems.
V2.32
  • Fix: Compiled against B4A 6.80 Core library to avoid some problems with CharSequences.
V3.00
  • Fix: Compiled against Support Library 28.0.0 to fix a problem with TabLayout
 

Attachments

  • FixedTabsExample2_00.zip
    23.4 KB · Views: 1,987
  • FloatLabelEditText1_0.zip
    8.2 KB · Views: 1,628
  • FloatingActionButton1_0.zip
    12.5 KB · Views: 1,747
  • ScrollingTabsExample2_00.zip
    8.3 KB · Views: 1,754
  • SnackBarExample2_00.zip
    7.7 KB · Views: 1,618
  • TabsWithCustomViewExample2_0.zip
    24.5 KB · Views: 1,884
  • NavigationView1_0.zip
    108.9 KB · Views: 2,542
  • BottomNavigationViewExample1_0.zip
    28.7 KB · Views: 1,784
  • DesignSupportLib2_31.zip
    58.3 KB · Views: 1,423
  • DesignSupportLib2_32.zip
    58.3 KB · Views: 2,182
  • DesignSupportLib3_00.zip
    65.9 KB · Views: 2,453
Last edited:

alimanam3386

Active Member
Licensed User
Longtime User
Hi

The NavigationItemClick does not works for me in new updated library [ I've tested your sample NavigationView1_0.zip ]

Edit:

yes it is working by bellow event:


B4X:
Sub Activity_ActionBarHomeClick
    Log("Yes, this one works here")
    If NavDrawer.IsDrawerOpen Then
        NavDrawer.CloseDrawer
    Else
        NavDrawer.OpenDrawer
    End If
End Sub

thank you
 
Last edited:

Inman

Well-Known Member
Licensed User
Longtime User
I see it too. Will upload a fix as soon as possible

Edit: Fixed in V2.23

Cool. It is working now.

Another question. Does DSFloatLabelEditText support Sender object? With an array of DSFloatLabelEditText views, I tried to get Sender inside TextChanged event but got a Null error. Again the same code works if it is EditText.
 

corwin42

Expert
Licensed User
Longtime User
Another question. Does DSFloatLabelEditText support Sender object? With an array of DSFloatLabelEditText views, I tried to get Sender inside TextChanged event but got a Null error. Again the same code works if it is EditText.

I haven't tested it but it should. I guess the sender is not the DSFloatLabelEditText but a normal EditText (or ACEditText) item.
 

Sapta

Member
Licensed User
Longtime User
Hi

The NavigationItemClick does not works for me in new updated library [ I've tested your sample NavigationView1_0.zip ]

Edit:

yes it is working by bellow event:


B4X:
Sub Activity_ActionBarHomeClick
    Log("Yes, this one works here")
    If NavDrawer.IsDrawerOpen Then
        NavDrawer.CloseDrawer
    Else
        NavDrawer.OpenDrawer
    End If
End Sub

thank you


Hi @alimanam3386,

I have same problem, when i click homebutton (homebutton of the Toolbar. The 3 line menu icon is animated) does not works for me in new updated library, i change code reference by your code, still not work? any solution?

B4X:
#Region ToolBar Events
'Open or Close the drawer if the Toolbar HomeButton is clicked.
Sub Activity_ActionBarHomeClick
    Log("Yes, this one works here")
    If NavDrawer.IsDrawerOpen Then
        NavDrawer.CloseDrawer
    Else
        NavDrawer.OpenDrawer
    End If
End Sub
#End Region
 

corwin42

Expert
Licensed User
Longtime User
Please start a new thread for this question in the questions forum. Homebutton and ToolBar have nothing to do with DesignSupport library.
 

johndb

Active Member
Licensed User
Longtime User
Is it possible to add an event that is triggered when a Snackbar finishes its display?
 

corwin42

Expert
Licensed User
Longtime User

corwin42

Expert
Licensed User
Longtime User
Updated library to version 2.30.

This adds a Dismissed event to the snackbar and supports CharSequences whereever possible.

Be aware that the snackbar needs a CoordinatorLayout to support swipe to dismiss.
I'm currently working on Coordinator Layout support but this is quite complex and very time consuming to test. Maybe the next version will have initial support for it.
 

johndb

Active Member
Licensed User
Longtime User
Updated library to version 2.30.

This adds a Dismissed event to the snackbar and supports CharSequences whereever possible.

Be aware that the snackbar needs a CoordinatorLayout to support swipe to dismiss.
I'm currently working on Coordinator Layout support but this is quite complex and very time consuming to test. Maybe the next version will have initial support for it.
I tried implementing the Dismissed event and received the following error:

java.lang.NoSuchMethodError: No virtual method addCallback(Landroid/support/design/widget/BaseTransientBottomBar$BaseCallback;)Landroid/support/design/widget/BaseTransientBottomBar; in class Landroid/support/design/widget/Snackbar; or its super classes (declaration of 'android.support.design.widget.Snackbar' appears in /data/app/com.scsoftstudios.aws-2/base.apk)
at de.amberhome.objects.SnackbarWrapper.Initialize(SnackbarWrapper.java:101)
at com.scsoftstudios.aws.actapp._save_click(actapp.java:550)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at com.scsoftstudios.aws.actapp$B4AMenuItemsClickListener.onMenuItemClick(actapp.java:191)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:148)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:957)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:947)
at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:616)
at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:153)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
 

corwin42

Expert
Licensed User
Longtime User
I tried implementing the Dismissed event and received the following error:

java.lang.NoSuchMethodError: No virtual method addCallback(Landroid/support/design/widget/BaseTransientBottomBar$BaseCallback

I guess that your support library is too old.
 

ivan.tellez

Active Member
Licensed User
Longtime User
Hi @corwin42

I just update this lib to 2.3 and AppCompat to V3.50:, Now I got an error

Unknow Type: JavaObject.lang.CharSequence

Do you need B4A 6.8 to use this lib update?

If yes, could you please publish previous versions?


Thanks


Edit: Corrected Error.
 
Last edited:

corwin42

Expert
Licensed User
Longtime User
Hi @corwin42

I just update this lib to 2.3 and AppCompat to V3.50:, Now I got an error

Unknow Type: JavaObject.Toolbar_NavigationItemClick.CharSequence

Do you need B4A 6.8 to use this lib update?

No. It should work with lower B4A versions.

When do you get the error? On compile time or at runtime? Can you please post the full error stack?
 

ivan.tellez

Active Member
Licensed User
Longtime User
When do you get the error? On compile time or at runtime?

Neither, its at design time, I just figured it out. My previous code:

B4X:
If TxtClave.Text.Length <> 10 Then
'some warning stuff
End if

But it works like this:

B4X:
Dim tString As String
tString = TxtClave.Text
If tString.Length <> 10 Then
'some warning stuff
End if
 

corwin42

Expert
Licensed User
Longtime User
In V2.31 (and AppCompat V3.51) the getters will return String instead of CharSequence again so the old syntax will work again.
 

corwin42

Expert
Licensed User
Longtime User
Hi @corwin42.
Is it possible to set the menu items size?

Which menu items you are talking about? The DesignSupport library does not have any Menu objects. If you are talking about the NavigationView there is no direct way to set the size. Maybe it is possible within the Theme but I'm not very familiar with it.
 

luke2012

Well-Known Member
Licensed User
Longtime User
@corwin42 & @Erel First of all thanks for your replies.
I'm talking about NavigationDrawer that is an "additional material design component" :)

In my case I'm talking about NavigationView.Item* (settings)

B4X:
NavDrawer.NavigationView.ItemTextColor = Colors.Black
 

corwin42

Expert
Licensed User
Longtime User
@corwin42 & @Erel First of all thanks for your replies.
I'm talking about NavigationDrawer that is an "additional material design component" :)

In my case I'm talking about NavigationView.Item* (settings)

I guess changing the text size will be possible with the CSBuilder object of B4A 6.80 since the menu supports CharSequence type.
 
Top