Android overlay text on notification drawable [duplicate] - java

This question already has answers here:
How to display count of notifications in app launcher icon [duplicate]
(5 answers)
Closed 6 years ago.
Currently, the notifications within my app are working great but if there are multiple notifications, then the whole status bar will be filled with them. Instead, I am looking to have one notification and then update that notification with text in a circle overlaying the notification icon to show the number of items.
The image below is what I am trying to achieve:
How can I achieve this programatically? As I am assuming that this would be the 'small icon' in the Notification Builder yet the small icon only accepts int (a resource layout int). If this cannot be done with the 'small icon' how would I achieve this with the 'large icon' (bitmap) or even set the normal icon (large) as the app icon & the small icon as an incrementing number?

What you can do is to create a custom notification with a custom layout. That way you can control everything that will be present on the Notification in both normal and big view.
Please refer : https://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomNotification

Related

How to create mobile ready layouts in Vaadin? [duplicate]

This question already has answers here:
Vaadin - Responsive Columns
(3 answers)
Closed 3 years ago.
How do I go about creating a layout or page with vaadin that works on both mobile and desktop screens? When I put things side by side, I can't override the styling to make them appear above or below one another no matter how specific I make the CSS.
HorizontalLayout layout = new HorizontalLayout();
layout.addComponents(new Label("Test"), new Label("Test"));
layout.addStyleName("my-layout");
HorizontalLayout is not meant for responsive layouts. If you want to create responsive layouts and use CSS use Div instead. There's an example here https://vaadin.com/tutorials/vaadin-key-concepts

Display an int number in notification bar icon Android

I would like to display an integer (from 0 to 10,000) as an icon in my android notification bar (like battery doctor). I searched in the forum and the best solution seems to be creating 10,000 drawable images for each number....It's simply impossible isn't there any other way to do that with the new versions of android ?

How to update icon dynamically in contacts for my android app?

I am working on a app which add its icon in android default contacts app just like whatsApp icon appears in contact info. I want to update my apps icon dynamically on receiving some events, say a user comes online, then icon in contact list should be different then the icon shown when user is offline.
Can anyone suggest any way to do this?
Thanks
I assume your contact list is a ListView, and that you have an adapter that inflates each cells layout (that is, displays the icon and name of the contact).
Whenever you detect a change has occurred (an event was received) (maybe consider using a Loader if you aren't already), you should be able to call Adapter.notifyDataSetChanged() to update the cells.

How do I scale a .JPEG to fit inside a button that rests in a GridView? [duplicate]

This question already has answers here:
resize jpeg image in java
(3 answers)
Closed 9 years ago.
I have a number of Buttons that are dynamically added to a GridView using an Adapter. These currently fit inside the GridView correctly, but...
I would like to add an image inside each button. I have banana.jpg stored in my drawable folder and I use the following code to set it inside the button:
button.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.banana));
However, I have two problems:
The buttons seem to stretch to the size of the image.
The image doesn't actually appear.
Is there some way to add an image to a button such that the current size of the button will scale the image down so that it fits? (Or, is it possible to calculate the size I will need the image to be so I can resize it manually?)
You have to use ImageButton instead of Button,
If you want to use Button may be This answer can help you.

Java Change Button Background Color [duplicate]

This question already has an answer here:
Java Swing button colors [duplicate]
(1 answer)
Closed 7 years ago.
I am using netbeans to create a desktop application, and I am trying to change the background color of a JButton, btn1 using the code
btn1.setBackground(Color.Red)
But this does not work. Instead of changing the fill color of the button, only the border color is changed. How can I change the background fill?
Thanks
See this related question and answer.
In particular, you can use setForeground() to change the color of a button's text, but the corresponding setBackground() doesn't read well on some platforms. Using a Border is one alternative; a colored panel, shown below, is another.
You can also try calling setOpaque(true) on your button.

Categories

Resources