Android Question using vector drawables for icons in Android 5+?

Dave O

Well-Known Member
Licensed User
Longtime User
Has anyone tried using the new VectorDrawable feature in B4A?

I'm wondering if I should use it for icons in future apps (for Android 5+, or with AppCompat for Android 4+).

Thanks!
 

DonManfred

Expert
Licensed User
Longtime User
Be my betatester :D

Setup:
- Download VectorDrawablesV1.0.zip and extract the files to your additional libraries folder.
- Download the Example and extract it.
- Go to https://github.com/MrBIMC/MaterialDesignIcons
and download the package there. Extract the package. Take the RES folder from your extracted files and copy it to the Example projectdir.
Rename the folder Res to Resources (as i used the foldername Resources in my examplecode)

Run the example.

B4X:
#AdditionalRes: ..\Resources

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim vd As VectorDrawable
    Private ImageView1 As ImageView
    Private ImageView2 As ImageView
    Private ImageView3 As ImageView
    Private ImageView4 As ImageView
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("Layout1")
    vd.Initialize("zzz_account_key")
    vd.ColorFilter = Colors.Red
    vd.Alpha = 255
    ImageView1.Background = vd.Current

    vd.Initialize("zzz_alarm_multiple")
    vd.ColorFilter = Colors.Blue
    vd.Alpha = 255
    ImageView2.Background = vd.Current

    vd.Initialize("zzz_android_debug_bridge")
    vd.ColorFilter = Colors.Magenta
    vd.Alpha = 255
    ImageView3.Background = vd.Current

    vd.Initialize("zzz_github_box")
    vd.ColorFilter = Colors.Red
    vd.Alpha = 255
    ImageView4.Background = vd.Current
End Sub


Screenshot_20160708-163233.png


PS:: You need B4A 6+ as the dependson is pointing to googles maven repository and uses the Android-Support-V4
B4X:
@DependsOn(values={"com.android.support:support-v4"})
 

Attachments

  • VectorDrawablesEx.zip
    7.7 KB · Views: 308
  • VectorDrawablesV1.0.zip
    2 KB · Views: 307
Upvote 0
Top