Skip to main content

Useful tips for new Sketchware users

Today, I will be sharing some useful tips that I wish I knew when I started using Sketchware. These tips will help you work faster and simplify the way you do tasks.

COPYING A LAYOUT

You've built a beautiful layout or someone shared a project with you and you want to replicate the layout on another activity. Instead of having to recreate it, you can highlight the layout that you want to copy and then click the save button.

Save layout

After you save a layout it will appear in your views just under the shared views icon

Shared view

You can then drag it from the list and use it again on another activity.

SAVE BLOCKS TO COLLECTIONS

After creating a complex or long sequence of blocks, instead of having to recreate them, you can copy them to your collections. These will be available in your collections and you can easily access and reuse them from there.

Save blocks to collections

NB- You still have to recreate variables and other components that you want to reuse on the new activity. These will not be imported unless they already exist. For example if I have a list string "countries" that I want to reuse on another page. I simply have to create a new list string countries then I can import my blocks.

USE MOREBLOCKS

Sketchware moreblocks

Moreblocks are meant to make it easier to do tasks and to keep your logic neat. As you add more features to your app, its logic will also become more complex. So instead of placing all your blocks in onCreate, you can use moreblocks. Say I want to check time, show welcome message, set text data and so on... I will only have the moreblocks in onCreate and then I know exactly where to go if I want to adjust the logic for checking time.

SAVE MOREBLOCKS TO COLLECTIONS

Save moreblock to collection


Say you have a moreblock that changes the font of all widgets in your app, instead of having to recreate it on each activity, you can save it to your collections and then import it from collections whenever you need it. In the screen above, the arrows sho how to add to collections. At the top of the screen, just under events, we have "Import from Collections" this is where your Moreblock will be saved.

USE WEIGHT PROPERTY FOR FLEXIBLE LAYOUTS

weight property


Phones come in various models and device sizes. This means that your app will not look the same on all screens. An easy way to avoid any problems that this might solve is to use the weight property instead of a fixed width and height. A weight of 1 takes up the available space on the screen. Think of it as a ratio... if weight is 1, then it takes up 1 or the entire space in that layout or screen. If the weight is 2, it means that our ratio is 2:1 meaning 2 items can fit on one screen. Weight sum is the total weight that a layout can accommodate. So a weight of 3 means it will take up 3 items with a weight of 1 each.

NAME YOUR LAYOUTS AND WIDGETS

Widget id


This might not be necessary when using a small number of widgets on an activity but as you build more complex logic, it is easier to identify widgets by their names in your logic. For example if I have edittext1, edittext2, edittext3 and edittext4, it's wise to rename them "username", "email", "password" and "confirm_password". This let's you know which item you are using. It also saves you from mismatches and it simplifies troubleshooting. Click on any item that you want to rename... once the properties menu appears, click "id" and give it a new name.

NB- Unless its convenient, avoid giving your widgets names like "value1", "value2." This might cause challenges when you now have to compile your data on one activity and you now have 6 items from different activity with the name "value1". Rather use names like "purchases", "weekly_purchases" and "sales"

CHOOSE A STYLE AND BE CONSISTENT

When naming your widgets and setting up your keys, you should come up with a style that works for you and be consistent. The listview keys and other items are case sensitive... so a minor difference such as capitalization of one key and not the other could cause you unnecessary headaches. So if you're going to use small letters, be consistent with it. If you're going to use underscore to separate characters, be consistent with it. You might remember what you're doing now, but after some months you probably won't.

BE WARY OF AUTOFILL

The autofill feature is very helpful in filling in information but I've noticed that at times it adds a space after the character sequence. The system views this blank space as an additional character. The challenge is that it's hard to identify the additional blank space especially if it's at the end of the character sequence. So you might get users saying I'm trying to login but I can't. In some instances it's because they used autofill and the blank space makes the sytem recognize that email is badly formatted.

I hope you found these tips very helpful. Here's to wishing you all the best as you continue to build that amazing app of yours.

Comments

Popular posts from this blog

Hip hop and RnB songs to apologize to your partner

Love is a beautiful thing, but it often goes wrong. This often leads to pain, suffering and sorrow.  Being imperfect beings, hearts tend to get broken all the time regardless how hard we may try to avoid it.  The heartbreak is often inadvertent but at times we find ourselves in the wrong. An oversight, a word unsaid or even a lapse in our judgement can cause our loved ones harm. This doesn't always have to be the end though. Oftentimes, relationships can be mended by simply uttering three simple words: "I AM SORRY". This article is a collection of some of my favourite 'I'm sorry' songs. I hope you'll enjoy these apology songs, but more importantly, I hope you will get a few quotables and some wisdom nuggets from them.  The best apology however, is to change behaviour (got that from a Jay Z interview) so as you apologize, please remember that it was your actions that hurt them. The best apology is one which involves you not repeating those same mistakes aga

How to easily create background notifications in Sketchware(original)

One of the keys to building a successful app is to find mechanisms that will keep your users engaged. You can do this by using background notifications. This tutorial will show you how to do that in Sketchware. We will cover: 1. How to create notifications in Sketchware 2. How to show these notifications even when the app is closed. We will start by creating a new project. If you do not know how to create a new project please check out this article here. Once we have created our project, let us create a more block to place our code. Navigate to the events menu and then to the moreblock section as shown in the image above. Create a moreBlock. I have created a moreblock with the name "BackgroundActivity" with a boolean variable named "run." See the image below for how to add the boolean variable. Place the following block in the moreBlock Background activity code: moveTaskToBack(_run); That will move our task to the background.  Please note, that at this point we have

Php date: How to get the first and last day of the week

In this tutorial, I'll show you how to get the first and last day of the week in php. By default, in PHP the week runs from Monday to Sunday. However we'll cover two methods to get the first and last day for both those who consider Sunday or Monday as their first day of the week. We will be using 2 functions to achieve this: date() strtotime() We will use a combination of these two functions and store the result in a variable.  How to get the first day of the week If you want to get Sunday, use this method: $firstday = date('l Y-m-d', strtotime("sunday -1 week")); echo $firstday; If you want to get the date for Monday, this current week, use this method: $monday = date('l Y-m-d', strtotime("monday -1 week ")); echo $monday; How to get the last day of the week The following code will give you Saturday as the last day of the current week. $lastday = date('l Y-m-d', strtotime("saturday 0 week")); echo $last