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,843
  • FloatLabelEditText1_0.zip
    8.2 KB · Views: 1,508
  • FloatingActionButton1_0.zip
    12.5 KB · Views: 1,602
  • ScrollingTabsExample2_00.zip
    8.3 KB · Views: 1,613
  • SnackBarExample2_00.zip
    7.7 KB · Views: 1,495
  • TabsWithCustomViewExample2_0.zip
    24.5 KB · Views: 1,738
  • NavigationView1_0.zip
    108.9 KB · Views: 2,404
  • BottomNavigationViewExample1_0.zip
    28.7 KB · Views: 1,640
  • DesignSupportLib2_31.zip
    58.3 KB · Views: 1,277
  • DesignSupportLib2_32.zip
    58.3 KB · Views: 2,033
  • DesignSupportLib3_00.zip
    65.9 KB · Views: 2,257
Last edited:

corwin42

Expert
Licensed User
Longtime User
Some words about future development of this library.

I'm planning to wrap more classes of the official design support library. I started to wrap the NavigationView but I decided to discard it again because I had some issues with it supporting the NavigationDrawer over StatusBar feature. I think the great MaterialDrawer library wrapped by @thedesolatesoul is a perfect solution we can get for B4A.
 

walterf25

Expert
Licensed User
Longtime User
This library is a wrapper to some of the objects of Googles Design Support library.

Currently it supports:
  • Snackbar - The new modern toastmessages
  • TabLayout - The new material like tabs with fixed tabs and scrolling tabs feature. Works standalone or together with AHViewPager library. Supports icons as tabs and custom layouts for the tabs. The Tablayout has B4A designer support.
Installation:
  1. This library depends on the AppCompat library. So do all the setup needed for AppCompat.
  2. Copy the DesignSupport.xml and DesignSupport.jar files to your CustomLibs folder
  3. Update your support library with the SDK Manager. Use at least support library v23.0.1. All older versions will probably work but have issues with the tablayout!
  4. Copy the android-support-design.jar from the Android SDK to your CustomLibs folder (You will find it in <SDK_HOME>\extras\android\support\design\libs)
Setup and usage:
  1. Setup your project like a project that uses AppCompat library.
  2. Add "#AdditionalRes: <SDK_HOME>\extras\android\support\design\res, android.support.design" to your main activity.




Version History:

V1.00
  • Initial version with SnackBar and TabLayout objects.

Screenshots:

View attachment 37940 View attachment 37941
View attachment 37942
Awesome work Bud, you rock!
 

Blue.Sky

Active Member
Licensed User
Longtime User
Hi
I get below error.What's solution?
B4A version: 5.20
Parsing code. (0.03s)
Compiling code. (0.10s)
Compiling layouts code. (0.01s)
Generating R file. Error
D:\software\android-sdk\android-sdk\extras\android\support\v7\appcompat\res\values-v23\styles_base.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
D:\software\android-sdk\android-sdk\extras\android\support\v7\appcompat\res\values-v23\styles_base_text.xml:19: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
 

FrankDev

Active Member
Licensed User
Longtime User
my error.


LogCat connected to: emulator-5554
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
** Activity (main) Create, isFirst = true **~e:main_activity_create (java line: 332)
java.lang.ClassCastException: example.tablayout.fixedtabsicon.main cannot be cast to android.support.v7.app.ActionBarActivity
at de.amberhome.objects.appcompat.ACToolBarWrapper.SetAsActionBar(ACToolBarWrapper.java:244)
at example.tablayout.fixedtabsicon.main._activity_create(main.java:332)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at example.tablayout.fixedtabsicon.main.afterFirstLayout(main.java:102)
at example.tablayout.fixedtabsicon.main.access$000(main.java:17)
at example.tablayout.fixedtabsicon.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: example.tablayout.fixedtabsicon.main cannot be cast to android.support.v7.app.ActionBarActivity
** Service (svrautostart) Create **
** Service (svrautostart) Start **
 

corwin42

Expert
Licensed User
Longtime User
@Blue.Sky
My guess is that you are not compiling with v23 android.jar. Check in "Configure Paths" dialog in B4A.

@FrankDev
Do you use latest AppCompat library?

@All
Be sure you have all libraries at the latest version.
- SDK support library v23.0.1
- AppCompat wrapper v2.00
- AHViewPager

And compile with v23 android.jar.
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Well, I don't know where's the problem. When trying to run snackbar (scrollingtabs doesn't run also), I get this error:
B4X:
B4A version: 5.20
Parsing code.    (0.01s)
Compiling code.    (0.51s)
Compiling layouts code.    (0.02s)
Generating R file.    (6.34s)
Compiling generated Java code.    Error
javac 1.8.0_45
src\de\amberhome\designsupport\snackbar\main.java:17: error: cannot find symbol
public class main extends android.support.v7.app.AppCompatActivity implements B4AActivity{
                                                ^
  symbol:   class AppCompatActivity
  location: package android.support.v7.app
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 errorv

I've downloaded android sdk v23 (and configured on path), appcompatv2.0 and sdk platform tools v23.01

Any idea ?
 
Last edited:

Anser

Well-Known Member
Licensed User
Longtime User
The Sample attached in the 1st post "TabsWithCustomViewExample1_0.zip" is not working.
It is expecting a lib named XmlViewEx

I could not find, so called XmlViewEx lib in this forum. Found a Class Module with that name posted by you. Added that Class module to the project, but I was getting so many errors.

All other samples posted by you in the post #1 is working fine. :)

Very nice lib.

Regards

Anser
 

Anser

Well-Known Member
Licensed User
Longtime User
Thanks for the info.

Need to hunt for the info on "How to compile a class to Lib" and the tools required. Anyway shall start the hunt. Looks like need Eclipse and other stuffs ;)
 

DonManfred

Expert
Licensed User
Longtime User
Installation:
  1. This library depends on the AppCompat library. So do all the setup needed for AppCompat.
  2. Copy the DesignSupport.xml and DesignSupport.jar files to your CustomLibs folder
  3. Update your support library with the SDK Manager. Use at least support library v23.0.1. All older versions will probably work but have issues with the tablayout!
  4. Copy the android-support-design.jar from the Android SDK to your CustomLibs folder (You will find it in <SDK_HOME>\extras\android\support\design\libs)

@corwin42
You should also mention that you need to compile the XmlViewEx to a library if not already done before. See #11 to #15

Maybe a good idea to add it to the description in #1
I fell into this trap too (but was able to do while downloading the class and compiling it to library) :)
 

corwin42

Expert
Licensed User
Longtime User
@corwin42
You should also mention that you need to compile the XmlViewEx to a library if not already done before. See #11 to #15

Maybe a good idea to add it to the description in #1
I fell into this trap too (but was able to do while downloading the class and compiling it to library) :)
Ok, I will add some more explanations next week. I was a bit stressed this week because we had to prepare a family weekend trip. I just wanted to release all this stuff.
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Well, I've found the problem; I suppose was my fault ;-(

When copying new android-support-v4.jar and android-support-v7-appcompat.jar to my libraries folder, the files didn't overwrite the old files.

So if anyone have/will have an error like:
B4X:
error: cannot find symbol
public class main extends android.support.v7.app.AppCompatActivity implements B4AActivity{
and android-support-v4.jar and android-support-v7-appcompat.jar are in libraries folder, the solution is to update this files to the new updated jar's from ....Android\android-sdk\extras\android\support\v7\appcompat\libs

Otherwise, great job @corwin42 !!
 
Top