Posts

Showing posts with the label ViewFlipper with flipping text

Automatic text switching using ViewFlipper in Sketchware

Image
In Sketchware, to display a list of sentences one by one by automatically switching to next sentence every few seconds, follow the steps given below. 1. In Sketchware project, in main.xml add a LinearLayout linear1 , with width and height as MATCH_PARENT. Set a beautiful image as background of linear1. 2. Add a CustomView customview.xml. In this add a TextView textview1 , with text size 40, width and height MATCH_PARENT, and gravity center_horizontal, center_vertical. 3. Add a String List string_list . 4. In onCreate , one by one add sentences to this list. 5. After adding items to string_list, use add source directly block and put following code in it. ViewFlipper viewFlipper = new ViewFlipper(this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(20, 20, 20, 20); layoutParams.gravity = Gravity.CENTER; viewFlipper.setLayoutParams(layoutPar...