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

  • 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.

  • FloatlabelEditText - An enhanced EditText object that supports a floating label, counter and error messages.

  • FloatingActionButton - A very simple Floating Action Button. Has show- and hide animations but is very simple.
  • NavigationDrawer - Material Design compliant Navigation Drawer. See NavigationView Example for detailed instructions.
  • BottomNavigationView - Material Design compliant Bottom Navigation View. See BottomNavigationView Example for detailed instructions.
Installation:
  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>



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,978
  • FloatLabelEditText1_0.zip
    8.2 KB · Views: 1,618
  • FloatingActionButton1_0.zip
    12.5 KB · Views: 1,733
  • ScrollingTabsExample2_00.zip
    8.3 KB · Views: 1,743
  • SnackBarExample2_00.zip
    7.7 KB · Views: 1,607
  • TabsWithCustomViewExample2_0.zip
    24.5 KB · Views: 1,873
  • NavigationView1_0.zip
    108.9 KB · Views: 2,527
  • BottomNavigationViewExample1_0.zip
    28.7 KB · Views: 1,773
  • DesignSupportLib2_31.zip
    58.3 KB · Views: 1,412
  • DesignSupportLib2_32.zip
    58.3 KB · Views: 2,171
  • DesignSupportLib3_00.zip
    65.9 KB · Views: 2,440
Last edited:

Scantech

Well-Known Member
Licensed User
Longtime User
There is a bug with Snackbar and program will not start.

Message = Unfortunately, app has stopped.

B4X:
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.amberhome.designsupport.snackbar/de.amberhome.designsupport.snackbar.main}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
    at android.app.ActivityThread.access$1000(ActivityThread.java:198)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6837)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
    at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:374)
    at de.amberhome.designsupport.snackbar.main.onCreate(main.java:50)
    at android.app.Activity.performCreate(Activity.java:6500)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
    ... 10 more

It happens when you set these attributes

B4X:
    #FullScreen: True
    #IncludeTitle: False



Runs ok with

B4X:
    #FullScreen: False
    #IncludeTitle: True
 

corwin42

Expert
Licensed User
Longtime User
Runs ok with

B4X:
    #FullScreen: False
    #IncludeTitle: True

#IncludeTitle: False is not supported with AppCompat. You have to disable the title/ActionBar in the theme file if you don't want it.
 

Scantech

Well-Known Member
Licensed User
Longtime User
#IncludeTitle: False is not supported with AppCompat. You have to disable the title/ActionBar in the theme file if you don't want it.
Thanks for your reply. If we disable it, then it applies to all of the activities. I want 2 of the activities with title. I assume there is no workaround for this. Oh well, I can make some adjustments.

Edit: I saw your solution in the other thread.
 
D

Deleted member 30048

Guest
Hello.

Compiling with support library v23.1, I have the next error:

C:\Program Files (x86)\Android\android-sdk\extras\android\support\design\res\layout\design_navigation_menu.xml:17: error: No resource identifier found for attribute 'layoutManager' in package 'example.tablayout.fixedtabsicon'

Thanks!
 

corwin42

Expert
Licensed User
Longtime User

v23.1 of design support library now depends on RecyclerView. We only need the resource files so add the following line to your app (change it to the correct path)

B4X:
#AdditionalRes: <SDK_HOME>\extras\android\support\v7\recyclerview\res, android.support.v7.recyclerview
 

M. Giray Ozkan

Member
Licensed User
Longtime User
Hi,

I want to change "textAllCaps" property in tablayout to false. How can I achieve this?

Thank you
 

chrjak

Active Member
Licensed User
Longtime User
Hey

Great work!

but i can't debug your projects

B4A version: 5.20
Parsing code. (0.00s)
Compiling code. (0.07s)
Compiling layouts code. (0.00s)
Generating R file. Error
C:\Android\android-sdk\extras\android\support\design\res\layout\design_navigation_menu.xml:17: error: No resource identifier found for attribute 'layoutManager' in package 'de.amberhome.designsupport.snackbar'


Path is correct
Android 23 in B4a Path dialog (23.0.1)
newest librarys (AHViewPager(v2.21), App Combat (v2.00))

I'm trying to compile the 'new ToastMessage' project
 

Pcbeta Rabbit

Member
Licensed User
Longtime User
I get this problem...
B4X:
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 332)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:208)
    at example.tablayout.customtabs.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.customtabs.main.afterFirstLayout(main.java:102)
    at example.tablayout.customtabs.main.access$000(main.java:17)
    at example.tablayout.customtabs.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 de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:54)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 18 more
Caused by: java.lang.NoClassDefFoundError: android.support.design.R$attr
    at android.support.design.widget.ThemeUtils.<clinit>(ThemeUtils.java:25)
    at android.support.design.widget.TabLayout.<init>(TabLayout.java:231)
    at android.support.design.widget.TabLayout.<init>(TabLayout.java:225)
    at android.support.design.widget.TabLayout.<init>(TabLayout.java:221)
    at de.amberhome.objects.TabLayoutWrapper.innerInitialize(TabLayoutWrapper.java:78)
    at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:65)
    at de.amberhome.objects.TabLayoutWrapper.Initialize(TabLayoutWrapper.java:44)
    at de.amberhome.objects.TabLayoutWrapper._initialize(TabLayoutWrapper.java:86)
    ... 22 more
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
 

DonManfred

Expert
Licensed User
Longtime User
Caused by: java.lang.NoClassDefFoundError: android.support.design.R$attr

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.
 

joneden

Active Member
Licensed User
Longtime User
Hi All,

Is there a way to determine which is the currently selected tab and also can you mark tabs as disabled so the user can't access them? I'm wanting them to use in sequence and want to make the latter tabs inaccessible until after certain events occur.

Regards

Jon
 

Anser

Well-Known Member
Licensed User
Longtime User
The following code will help you to identify the currently selected tab. Its already there in the samples provided in the post #1
B4X:
Sub VP_PageChanged (Position As Int)
    ToastMessageShow("Page Changed to: " & Position,False)
    If Position = 0 Then    'User swiped and moved to the First page

    Else If Position =     1 Then    'User moved to page 2

    End If
End Sub

Hope this helps you.

Regards
Anser
 

joneden

Active Member
Licensed User
Longtime User
Thanks Anser,

I'd been looking at the TabLayout object I see that there is a CurrentPage property on the ViewPager object and that is even easier than having an event. That said if I can't find a way to disable tabs then I may need the event to switch tabs back to what they should be!
 

corwin42

Expert
Licensed User
Longtime User
I want to change "textAllCaps" property in tablayout to false. How can I achieve this?

There is no easy way to do this. In a Java project it would be possible to define a custom style for the tablayout. This is not supported in the B4A library. The only way to do it is with a custom view.

Generating R file. Error
C:\Android\android-sdk\extras\android\support\design\res\layout\design_navigation_menu.xml:17: error: No resource identifier found for attribute 'layoutManager' in package 'de.amberhome.designsupport.snackbar'

In v23.1 of the support libraries there is a dependency from design support to recyclerview. For this we need an additional #AdditionalRes attribute for the projects. I added this line to the setup description in the first post or see this post. I will update the examples in the next days.


If you use a ViewPager together with the TabLayout you can use the CurrentPage property of the ViewPager. If you use the TabLayout standalone there is no other way than using the "TabSelected" event.
There is no way of disabling a single tab.
 

joneden

Active Member
Licensed User
Longtime User
If you use a ViewPager together with the TabLayout you can use the CurrentPage property of the ViewPager. If you use the TabLayout standalone there is no other way than using the "TabSelected" event.
There is no way of disabling a single tab.

Thanks for letting me know. I'll intercept it the page change and modify the active page in there.
 

mdhugol

Member
Licensed User
Longtime User
My build always throw an error every time use TabLayout.TabIndicatorColor Properties.

Debug always says NoSuchMethod, But if i remove the declaration, application build successfully

I'm using Android Support Library 23.1.0

B4X:
TabLayout.TabIndicatorColor = Colors.White
java.lang.NoSuchMethodError: android.support.design.widget.TabLayout.setSelectedTabIndicatorColor

Anyone facing the same problem here.?
 

woniol

Active Member
Licensed User
Longtime User
Hi,
I noticed a small bug with the new PageLayout used with ViewPager.

First scroll between tabs works fine, but then with another scroll the tab indicator is not moved proportionally(together) with the page turn but at the end of the page scroll. When I scroll very slow, tab indicator changes, but after clicking on the other tab name(icon) it sometimes gets out of synch with the page.

I can be reproduced using the examples form the first post.
Tested on real device (Galaxy S5) with Android 5.0

[Solved]
Looks like it was a problem with prior v23.0.1.support library.
When compiled with support library v23.0.1 it works fine.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
[Solved]
Looks like it was a problem with prior v23.0.1.support library.
When compiled with support library v23.0.1 it works fine.

See post #1:
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!
 

corwin42

Expert
Licensed User
Longtime User

I'm 99.9% sure that you have an old android-support-design.jar in your customlibs folder.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…