Posts

Showing posts with the label CardView example in Sketchware

Androidx CardView in Sketchware

Image
To add multiple CardViews with text contents on a page, as shown in image below, follow the steps given below. 1. In VIEW area of  main.xml  add a ScrollView with padding 0. Inside ScrollView add a LinearV linear1 . Inside linear1 add 9 LinearH. 2. Switch On AppCompat and design. 3. Create a Custom View text.xml. In text.xml add a TextView textview1 . 4. Add a String List mylist . 5. In  onCreate  event: a. Add 9 items to the String List. b. Then add following codes in add source directly block // Create a loop from 0 to to child count of linear1 for (int i = 0; i < linear1.getChildCount(); i++){ // For each i in loop create a CardView, set it's radius and elevation, and add it to the child at 1 of linear1. androidx.cardview.widget.CardView card = new androidx.cardview.widget.CardView(this); card.setRadius(30); card.setCardElevation(20); ((ViewGroup)linear1.getChildAt(i)).addView(card); // Get Custom View and the TextView in Custo...