How to create arrow type layout? - android

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

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.

Drawable color changes, but after changing activity remains

I have a menu, with several buttons and its drawables. This menu is included in 4 activitys.
I am setting the drawable color programmatically:
mDrawable.setColorFilter (0xff0099cc, PorterDuff.Mode.SRC_IN);
The first button by default is enabled, so the color is changed programmatically. When I press another button to go to another activity, the other button changes the color, but the first one remains as if it had activated.
You are not clear about your drawable and so I ll give generic solution to you.
You can just use Drawable.setColorFilter( 0xffff0000, Mode.MULTIPLY ). If you could make the entire image WHITE (FFFFFF) so that when you do PorterDuff.Mode.MULTIPLY, you end up with the correct colors. Note this would not affect the transparent pixels.
For solid images, it is best to use the color filter PorterDuff.Mode.SRC_ATOP because it will overlay the color on top of the source image, allowing you to change the color to the exact color you are looking for.
Let me know, whether it helps.

Material Color Reveal via Radial Reaction

In Android, a feature called radial reaction exists (find it at https://material.google.com/motion/choreography.html#choreography-radial-reaction).
After a bit of research, I discovered that we can use this to reveal views (see http://android-developers.blogspot.com/2014/10/implementing-material-design-in-your.html and http://pulse7.net/android/android-create-circular-reveal-animation-and-ripple-effect-like-whatsapp/).
Is it possible to reveal a certain color, instead of a view? (For example, change the background color to red when the user clicks the layout)
For now, only revealing a view is supported out-of-the box in ViewAnimationUtils https://developer.android.com/reference/android/view/ViewAnimationUtils.html
You could have your layout file define two different background layouts (LinearLayouts for example). The circular reveal would reveal whichever view you need.

How to create clickable star in toolbar in an app?

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

Android Custom Image Buttons

I'm new to Android development and I'm trying to implement some custom buttons, they should look something like this:
So I was wondering if I can use something like a imagebutton and use the image as a background and add text on top of it (I tried this but the text is always in the middle and doesn't have a label so its hard to see..), or should I write a custom style or theme for my button. In case that I have to write a custom style or theme, could you please help me out with this? How should I go about doing it?
For each of those Grid elements, create a framelayout for each, put the background and then the label in front. Frame layouts allow things on top of each other. You can put the labels with layout_gravity bottom and also add a transparent color to it so the image in the back can be seen. Also add a onClickListener to each of the framelayouts so they act as buttons.

Categories

Resources