How to create clickable star in toolbar in an app? - android

I am working on an android application that requires me to give an option of marking objects as favorite. I am planning of creating a clickable star on the right corner of the toolbar. So, when I click on that star it should become yellow and should be dull color star otherwise. Is there a way I can do that ?

You can create two images. One of the star without the yellow background. set an on click listener for it. and on click you can change the image to the one which has the yellow background.
hope this helps

Related

How to set click event on a triangular view (as in the given image shapes)?

I have an issue regarding design 'Setting screen' for my app. In this screen I need to design circular menu options in a triangular shape and I need to set OnClickListener only on the triangular area, which is only visible option border area. I can't understand what approach I need to use to achieve this design as well as set OnClickListener.

Bottom Navigation - show dot under active item

I tried to find any similar question, but i didn't succeed. I want to use bottom navigation with my own design. It looks like this:
Is there any way to place the dot under the active item icon? I tried to create the active icon already with dot in one PNG, but in this case the icon became smaller than other two.. Appreciate any help.

Ratingbar on App Widget, is there a way to insert it?

I know that Rating bar is not in the list of remoteView compatibile classes, but I saw some widget with a rating bar working fine, how is it possible?
Should I simulate it with some star buttons?
Thanks
I solved in a bad way. I put on the widget a button (with a star drawable) for each star in need in the rating bar, then for each button star I give different OnClickListeners that corresponds to the star number. For example, the first star button has the OnclickLister 'firstStarPressed'. In this method the button star drawable is updated to a filled star drawable.
I got rid of ugly, but it works

How to create arrow type layout?

I have start and end date time fields that look like in picture below. Blue color shows active selection - if we select right then blue color goes to right and white color appears on the left and vice versa.
Hardest part is to create that arrow style in the middle. What should i use because buttons are rectangles and I don't know how it could be done.
It's easy. Just use ninepatch.
You can start there:
http://radleymarx.com/blog/simple-guide-to-9-patch/
you need a custom image according to what you ask, maybe extend ToggleButton for that but basically what you want is the same component when pressing on two different places on the same component will dispatch different events.
I would for example extend Linear layout, make it vertical layout, put two clickable textView\buttons with 9 patch images as background ,like suggested before, one for the white part and the other for the blue part. and replace the background image for any event u like.
you can also create a StateListDrawable with actions for selected and deselected and set the state of each drawable upon the right click

Change the truck color of a listview in android

I'm not sure if it's called the truck in the world of java, but I've always referred to the scroll bar size thing as a truck. That bit on the right that gets smaller as there are more items in the list, and that stays relative to the current scroll position. Truck? Right?
Well regardless of what it's called, does anyone know how to change it from white to another color. I've a list with green text in it, and in fact all my controls are green on a black background. It looks quite spunky and fun. But for the "truck"; it remains white.
Does anyone know how to change the truck color?
Just do
android:scrollbarThumbVertical="#drawable/scrollbar_vertical_thumb"
and let scrollbar_vertical_thumb be a gradient
refer to this

Categories

Resources