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.

Comments

  1. How to load image from url in listview

    ReplyDelete
  2. Great job. Is it possible make push notifications?

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hi Sanjeev,
    How can we get the current location of the device (GPS)?
    THANKS!

    ReplyDelete
  5. A 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

    ReplyDelete
  6. Is it necessary to upload the app to play store? Isn't it possible that two people download it from sketchware only?

    ReplyDelete
    Replies
    1. You can send the apk file to your friend, no need to upload to play store

      Delete
  7. How to add chat rooms in chatting App?

    ReplyDelete
  8. How to make notification of this chat app?

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Guys 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

    ReplyDelete
    Replies
    1. Tell your friend to free up some space and try again

      Delete
    2. Maybe you don't have enough storage space

      Delete
  11. Visit my blog perfect Login With Email Verification https://sketchwarehelptech.blogspot.com/2019/09/perfect-login-with-email-verification.html

    ReplyDelete
  12. Can you make a chat app where you chat with friends? If you have their numbers like WhatsApp.

    ReplyDelete
  13. is it possible to send sms directly through created app because it opens regular messaging app and i have to type and send the sms

    ReplyDelete
  14. Maybe you don't have enough storage space

    ReplyDelete
  15. Someone should send me a PDF on how to create a chat app using sketchware . Thanks
    tochukas@gmail.com

    ReplyDelete
  16. 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.
    free tamil chatting site

    ReplyDelete
  17. 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

    ReplyDelete
  18. Very 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

    ReplyDelete
  19. Video 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.

    ReplyDelete
  20. I 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.

    ReplyDelete
  21. I 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

Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware