Codes to improve firebase chatting app in sketchware
Here are a few codes which can be used in the chat application created using Firebase in Sketchware.
1. Remove divider height of ListView
To remove the divider height of ListView displaying messages, put following code in onCreate, in an add source directly block.
listview1.setDivider(null);
listview1.setDividerHeight(0);
2. Display end of ListView on refresh
To make the ListView scroll to display the last element of list when updated, put following code in onCreate, in an add source directly block.
listview1.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
listview1.setStackFromBottom(true);
3. Set width of ListView items to 3/4 of screen width
Firstly, in CustomView, insert a LinearH linear1, and inside that insert a LinearV linear2. Put all contents to be displayed in linear2.
Now, in event onBindCustomView, add a number variable width. Set width to getDisplayWidthPixels * 0.75, and set it as width of linear2 using following code.
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)width, LinearLayout.LayoutParams.WRAP_CONTENT);
linear2.setLayoutParams(lp);
4. Rounded corners and Custom background color
In onBindCustomView event, add a add source directly block and put code to create a GradientDrawable with custom background color and rounded corners, as given below, and set it as background of linear2.
android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable();
gd.setColor(Color.parseColor("#ffffff"));
gd.setCornerRadius(60);
linear2.setBackground(gd);
5. Display messages of device user on right and those of others on left.
To display messages of user on right and those of others on left, in onBindCustomView event, use blocks as shown in image above. The code used is:
If File user getData key username equals (get value at position key name of List Map map1) then,
linear1.setGravity(Gravity.RIGHT);
else,
linear1.setGravity(Gravity.LEFT);
6. Hide Keyboard on button click
Add following code in on button click event.
android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
To understand more watch the video below.
1. Remove divider height of ListView
To remove the divider height of ListView displaying messages, put following code in onCreate, in an add source directly block.
listview1.setDivider(null);
listview1.setDividerHeight(0);
2. Display end of ListView on refresh
To make the ListView scroll to display the last element of list when updated, put following code in onCreate, in an add source directly block.
listview1.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
listview1.setStackFromBottom(true);
3. Set width of ListView items to 3/4 of screen width
Firstly, in CustomView, insert a LinearH linear1, and inside that insert a LinearV linear2. Put all contents to be displayed in linear2.
Now, in event onBindCustomView, add a number variable width. Set width to getDisplayWidthPixels * 0.75, and set it as width of linear2 using following code.
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)width, LinearLayout.LayoutParams.WRAP_CONTENT);
linear2.setLayoutParams(lp);
4. Rounded corners and Custom background color
In onBindCustomView event, add a add source directly block and put code to create a GradientDrawable with custom background color and rounded corners, as given below, and set it as background of linear2.
android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable();
gd.setColor(Color.parseColor("#ffffff"));
gd.setCornerRadius(60);
linear2.setBackground(gd);
5. Display messages of device user on right and those of others on left.
To display messages of user on right and those of others on left, in onBindCustomView event, use blocks as shown in image above. The code used is:
If File user getData key username equals (get value at position key name of List Map map1) then,
linear1.setGravity(Gravity.RIGHT);
else,
linear1.setGravity(Gravity.LEFT);
6. Hide Keyboard on button click
Add following code in on button click event.
android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
To understand more watch the video below.
How to load image from url in listview
ReplyDeleteBruh there's a block for that
DeleteGreat job. Is it possible make push notifications?
ReplyDeleteYeh
DeleteThis comment has been removed by the author.
ReplyDeleteHi Sanjeev,
ReplyDeleteHow can we get the current location of the device (GPS)?
THANKS!
Avec le component location manager
DeleteA questão da ListView quando atualiza a lista ela rola automaticamente para baixo, tem como fazer ela atualizar mais manter a tela na mesma posição? Desde já agradeço
ReplyDeleteIs it necessary to upload the app to play store? Isn't it possible that two people download it from sketchware only?
ReplyDeleteYou can send the apk file to your friend, no need to upload to play store
DeleteHow to add chat rooms in chatting App?
ReplyDeletehow to make a video call?
ReplyDeleteHow to make notification of this chat app?
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGuys what will be happening if my app doesn't open if I send it to another user with android 8.0 mobile phone and the app doesn't open . .it says app not installed
ReplyDeleteTell your friend to free up some space and try again
DeleteMaybe you don't have enough storage space
DeleteVisit my blog perfect Login With Email Verification https://sketchwarehelptech.blogspot.com/2019/09/perfect-login-with-email-verification.html
ReplyDeleteCan you make a chat app where you chat with friends? If you have their numbers like WhatsApp.
ReplyDeleteis it possible to send sms directly through created app because it opens regular messaging app and i have to type and send the sms
ReplyDeleteMaybe you don't have enough storage space
ReplyDeleteSomeone should send me a PDF on how to create a chat app using sketchware . Thanks
ReplyDeletetochukas@gmail.com
Very interesting. Your article is so convincing that I can never stop myself from saying anything about it. You are doing a great job, thanks for sharing such a great blog.
ReplyDeletefree tamil chatting site
I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.Spam Free Chat Rooms for Online Chat USA
ReplyDeleteThis comment is comment
ReplyDeleteVery good knowledge, You have provided excellent information for us. It is valuable and informative for everyone. Keep posting always. I am very thankful to you. Thanks once again for sharing it. Poly Dating Sites
ReplyDeleteVideo chat rooms I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.
ReplyDeleteI generally check this kind of article and I found your article which is related to my interest. Genuinely it is good and instructive information, matchmaking services san diego Thankful to you for sharing an article like this.
ReplyDeleteI consider this to be information of quality and it appears to be written so as to make the reader think. I like your writing style and appreciate your efforts.free chat now allows two users to connect with each other in a chat room where they can start a chat now without registration. Free chat now with anyone without revealing your identity.
ReplyDelete