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,350
Last edited:

bluedude

Well-Known Member
Licensed User
Longtime User
Alright, i'm waiting for the masterpiece. I want to start on a Kitchensink app for Lollipop soon.
 

woniol

Active Member
Licensed User
Longtime User
Hi,
Is it possible to change the Elevation in code after it was set before.
When i try to do it I get black border like this:
upload_2014-12-12_10-51-33.png


my code:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim cv2 As MSCardView
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Private WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
   
    Activity.Color = Colors.LightGray
   
    Dim spanel As Panel
    spanel.Initialize("")
    Activity.AddView(spanel, 0dip, 0dip, 100%x, 100%y)

'Create the CardViews
   Dim cv As MSCardView
    cv.Initialize("CV")
    cv.MaxElevation = 5dip
    cv.Elevation = 5dip
    cv.Radius = 0
    spanel.AddView(cv, 10dip, 255dip, 100dip, 100dip)

   
    cv2.Initialize("CV2")
    cv2.MaxElevation = 10dip
    cv2.Elevation = 2dip
    cv2.Radius = 0
    spanel.AddView(cv2, 10dip, 370dip, 150dip, 100dip)
 
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub CV_Click
    Log (cv2.Elevation)
    cv2.Elevation = 3dip
    cv2.Invalidate
End Sub
 

Attachments

  • upload_2014-12-12_10-50-58.png
    upload_2014-12-12_10-50-58.png
    297.3 KB · Views: 156

thedesolatesoul

Expert
Licensed User
Longtime User

Peter Simpson

Expert
Licensed User
Longtime User
Hiya all,
This is my attempt at an Android 5.0 Lollipop look and feel, it all started with this library.

Attached you will find the zip file for this bad attempt at manipulating MSCardView, MSMaterialMenu(BURGER and ARROW only, no X), StdActionBar, StdActionBarHelper, AHNavigationDrawer and mListView. I hope that you find this code useful, you can easily manipulate all the colours and the Navigationdrawer to suite your apps look and feel.
1.png

2.png


Enjoy...
 

Attachments

  • Android 5.0 Material Design.zip
    60.6 KB · Views: 502
Last edited:

bluedude

Well-Known Member
Licensed User
Longtime User
Interesting, however the MMenu with setTransformationOffset seems to be not working. This method isn't in there.
 

thedesolatesoul

Expert
Licensed User
Longtime User
Interesting, however the MMenu with setTransformationOffset seems to be not working. This method isn't in there.
It is in the last version posted somewhere in that thread.
I need to clean up that library but I really dont have the time.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Trying to run it on 4.4.4., getting attached error. I have the support\v7 files it seems.
 

Attachments

  • error.png
    error.png
    208.1 KB · Views: 204

corwin42

Expert
Licensed User
Longtime User
Trying to run it on 4.4.4., getting attached error. I have the support\v7 files it seems.

Look in "Configure Paths" in the IDE menu. You should configure the android.jar to be at least platform version 21.
 

freedom2000

Well-Known Member
Licensed User
Longtime User
It is in the last version posted somewhere in that thread.
I need to clean up that library but I really dont have the time.
Hi,

@thedesolatesoul : Thank you for this very nice library.

I have just tested Peter's example. It works well but...
I confirm that, with the 0.93 version, the MMenu with setTransformationOffset seems to be not working.
 

thedesolatesoul

Expert
Licensed User
Longtime User
Top