B4A Library MSCardView

poBu7IQl.png


This library ports the CardView present in the android v7 compatibility libraries.
CardView is used to show information organized as cards. You can use these cards in a scrollview or a listview (ULV) or gridview etc.
The CardView is just a view that contains a panel.

Setup:
You do not need to reference and library to work with this, however you need to reference the resource files.
Add the following in your project attributes:
B4X:
#AdditionalRes: H:\Eclipse\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\cardview\res
*Replace the path with your AndroidSDK path. Also note you need to update your SDK and support libraries.

Copy MSCardView.xml and MSCardView.jar from this post into your Addtional Libraries folder.

CardView Specific Properties and Methods:
MaxElevation, Elevation, Radius, setPadding
These are all self explanatory.

Using CardView:

Example usage:
B4X:
'Create a Holder panel
Dim spanel AsPanel

spanel.Initialize("")
Activity.AddView(spanel, 0dip, 0dip, 100%x, 100%y)

'Create the CardViews
   Dim cv As MSCardView
    cv.Initialize("CV")
    cv.MaxElevation = 10dip
    cv.Elevation = 4dip
    spanel.AddView(cv, 10dip, 255dip, 100%x - 20dip, 96dip)

    Dim cv2,cv3 As MSCardView
    cv2.Initialize("")
    cv3.Initialize("")
    spanel.AddView(cv2, 10dip, 370dip, 50%x - 20dip, 60dip)
    spanel.AddView(cv3, 50%x , 370dip, 50%x - 20dip, 60dip)

    cv2.Radius = 50
    cv3.MaxElevation = 1dip
    cv3.Elevation = 2dip
    Dim etnew As EditText
    etnew.Initialize("")
    cv3.setPadding(50dip,5dip,10dip,5dip)
    cv3.Panel.AddView(etnew,0,0,-1,-1)

MSCardView
Author:
thedesolatesoul
Version: 0.01
  • MSCardView
    Methods:
    • BringToFront
    • 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)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • setPadding (l As Int, t As Int, r As Int, b As Int)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Elevation As Float
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • MaxElevation As Float
    • Panel As PanelWrapper [read only]
    • Radius As Float
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • MSCardView.zip
    25.7 KB · Views: 1,586
Last edited:

woniol

Active Member
Licensed User
Longtime User
Hi,
Are those screenshots from B4A?
I'm very interested in the new Android L Toolbar.
 

thedesolatesoul

Expert
Licensed User
Longtime User
Hi,
Are those screenshots from B4A?
I'm very interested in the new Android L Toolbar.
Yes, those are from B4A, but both are using two different approaches.
I built the first one when Toolbar wasnt available or known, so I actually extended and themed the Standard Actionbar. (using a combinated of xml and code).
The second one is actually just a panel.
I realized the Toolbar is actually just a viewgroup/panel in reality.
 

woniol

Active Member
Licensed User
Longtime User
Thanks for the info.
That's what i'm going to do - just use a panel with new SetLayoutAnimated. It gives Android L look :)
 

Peter Simpson

Expert
Licensed User
Longtime User
This is awesome stuff @thedesolatesoul. Only V0.01, no complaints from me.

No support for designer (yet). I can wait
No events are raised (yet). I can still, just :)

This library has come in the nick of time for me, Radius and Elevation are exactly I've been looking for. In the next week or two I'm aiming to start re-develop my main business app. This library will definitely come in handy.

Cheers H :cool:
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
I would say mainly the Click event H. Personally I think that the designer could wait, but the Click even would come in handy.

I will admit it, my apps especially my main app has a lot text boxes, labels and buttons. So I usually rely on the designer and the designer script a lot. I usually design the main layouts in the designer (buttons, text boxes etc), then I add the tables via code as you must do :)
 

Peter Simpson

Expert
Licensed User
Longtime User
What do the the -1's mean in the following line CV3.Panel.AddView(TxtEdit, 0dip, 0dip, -1, -1). I always though that you HAD to have an actual size in there...
 
Top