Highlight a Imagebutton to show notifications - android

I have an application in which you can accept friend request. For this purpose i have kept an activity which will start when an image button is pressed.
When my application starts i want to check if the user has any requests and if yes the button should be highlighted.
How do i do this?

Take another highlighted colour image. and Set TextView on that image.
Ex: RelativeLayout for that RelativeLayout background is your highlighted colour image then set TextView on that RelativeLayout.
Based on your condition put this image and number of pendings to TextView

you could make two imagebuttons. One which is in your normal colour and one in the highlighted colour, which are on the same place.
Depending on the situation you make either the one or the other (in-)visible.

Related

I can't see buttons in MaterialButtonToggleGroup

I want to use the toggle button group to make it look like the picture below.
enter image description here
However, if I insert a button into the toggleButton Group, the size of the button becomes very small. Even if the absolute size is given to each layout, only the size of the toggle Button Group is enlarged and the button inside is small, so I can't see it. When you take out the button, it returns to its normal size and you can see it well, but it looks small only in the group.
Can I know the reasons about this?
I am guessing that there must be separate styles in the toggleButton Group itself for buttons. Maybe you wanna check that.
Another reason I'm thinking is that maybe you have the width of the button set with % percentage, or with vh/vw(view height/width). If so button will change its size relative to the parent element size.

How to add some labels on a photo and show a text when i touch each label

I'm developing android app that handle some processes on photos
like zoom, blur, crop and so on.
for now, i have a one photo
and i just wanna put some labels on this photo on a specific places
And when i touch the label it shows me a text
How to do it ??
create 2 textViews one for label and another for your Text
set the second textView visibility to gone
setOnClickListener on the first TextView :- set visibility for the second text to Visible

Android Development make Buttons work like RadioButtons

I have 11 Buttons with Background Images and if i switch to the actual RadioButton the circle thing on the RadioButton would show up and make my Background drawables ugly is there a way to make buttons work like RadioButtons?
I'm assuming the image changes when you click on the button to show it is selected. In that case, in your onclicklistener for the first button, you could change the image of that button to show it is selected, and also change the images of the other buttons to the unselected image. Do the same for each button.

Android custom shape button or imageview hit area

Here is the scenario; I have 3 PNG photos i wanna use as background of buttons or ImageViews and they are overlapping in a relative layout. kinda like this:
so the red button will be the biggest and go under all of them, then i will add green button on top of red and then yellow button on top of green. so that's how it looks like. each button has a PNG background as i said at the beginning.
Problem is I cant make the only visible area of each Button/ImageView clickable! Android kinda considers each at rectangle button/ImageView.
Any solution for this?
In your onTouchListener you should check whether the event (MotionEvent) is in the transparent area of the background or not.
Either you can make a separate onTouchListener for each view/button and return false if the event is in the transparent area (of the View argument) or you can make a single listener for all of the buttons, ignore the View argument and check all of your three views to determine in which one the event is.

Android: Text container width inside a button

I try to do a custom keyboard, so I have a small buttons and the text doesn't fit in my buttons, but it have a few pixels for it:
Can I increase text container width inside my buttons?
You can try:
set button Paddings to zero:
button.setPadding(0,0,0,0);
(I dont really know how custom keyboards work but you may try using TextViews instead of Buttons, and you can set your Image or Background to your TextView aswell. Can use pressed states with selectors and etc...)
Or you can make your own class, and #Override their onDraw method to draw your own text(or charachter) for your view.
As far as i know there are no specific methods to increase text container.
You may consider using ImageButton instead of an ordinary Button as keyboard buttons. As you will have the freedom to edit the image the way you want to.

Categories

Resources