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,