I'm working on cross-platform mobile Unity application. I want add a switch on my screen allowing user turn on and off some functionality (like this: Android Material Switch).
As I know there is no native implementation of UI Switches in Unity. I found only this asset (Switch UI element) in Unity Asset Store, but it has really poor design.
So should I manually implement the Material Switch? Or is there anything in the web I can use in this case?
Thanks for response.
You can use slider as switch.
Here are simple steps:
Create a slider by going to GameObject->UI->Slider
Check whole numbers chech-box in slider component's inspector.
set min value to 0 and max value to 1.
Use whatever graphics you want (even from material design)
Register "OnValueChange" method to handle change in value:
public void SliderValueChanged(float value)
{
if(value == 0)
// off
else
// on
}
Probably I'm a bit late, but for anyone who is viewing this question, I found a fairly good (free) Asset called Lean GUI with switches and stuff.
Hope it'll help someone.
Related
I am in a situation like i have to generate UI Controls like Button,Switcher,Progress Bar, Label text etc based on my list Items .
I am looking for a way to generate the controls in a View and add Views with generated controls in a Layout .
Can anyone give me a proper way to do that?
Why not to use Fragments?
Google docs about this here
and little tutorial here
You may want to take a look at the Metawidget source code. The Android version of Metawidget makes extensive use of generating Views and Layouts at runtime (e.g. see org.metawidget.android.widget.widgetbuilder.AndroidWidgetBuilder). You may even find Metawidget itself will suit your needs (it's designed to be embedded into projects for use-cases such as this).
I have an app for iphone and I have to make it for android,I need to make a stepper,like in image,I know that I can make two buttons to increment and to decrement the value but I want to something that already exists if it exists
(onclick + value++ ,onclick - value--)
Have a look at the ZoomButtonsController widget, it has the looks, you only have to modify the bahaviour How do I use Android ZoomButtonsController?
I don't know if this is relevant to you use case now. But I've been looking for something very similar for quite some time. Here I've found a library that implements material design and solves my use case pretty well.
Hope this helps you. or someone else.
Is there an easy way to implement property animation(e.g. animate "x" or "y" property from value1 to value2) in android < 3.0? I need to animate a visual control(Button or TextView), that needs to handle click events(so, drawable animation is not appropriate).
Update:
So, there is a lot of games with animation(Cut the Rope, etc.). How these game developers solved the problem? What the way they use for animation?
I know this is an old thread, but for those who stumble across this in a Google search, there is a compatibility library available that gives you access to the property animations introduced with Honeycomb all the way back to Android 1.0.
I've used it for some small things, and it works like a charm. http://nineoldandroids.com/
Afaik, for this to work you have to roll your own animation framework first that interpolates the values the way you'd like. Then, you could animate e.g. the margin property of the button with this framework, calling .setLayout() on every tick. This causes the ui-framework to relayout/redraw the whole screen, with the new margin value.
However, this is a terribly slow and wasteful way to animate and I don't recommend it. There might be better solutions.
I know basic level Android, but haven't had done animation before. Moreover, I don't have any clue as to how can I create custom Geometrical objects like triangle, Hexagon, etc.
Moreover, I don't know anything about doing animation in Android. I'd like to have relevant tutorial links or blogs which can help understand the basics and preferable a sample code for "Rotation" animation.
Thanks in advance.
http://code.google.com/p/nehe-android/ (the code is best documentation ^_^)
but it is for open gl custom objects on top of your view/surface view, it is commonly used in games.
If you want to do just rotation for Button, there are http://developer.android.com/reference/android/view/animation/Animation.html and subclasses of it (RotateAnimation and so on), you can even do a custom one. By this way you can do awesome user experience for application which use default android controls.
Cheers
I'm developing an application for Android using Burrito, and I came across a certain situation that I can't seem to find out how to solve. Which is, how do you change the ActionBar look and feel?
I can create a skin with the class ActionBar as its host component but (I hate buts so much) how do you actually use it then? How do you apply it to a view? It's just because I want to change its height. I don't really see any problem in it but my boss wants it smaller, so how can I accomplish this?
1) Try to change the look&feel with css color schemes such as backgroundColor, color, ... (full list here: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f85.html)
3) If you need more advanced styling/skinning, good luck because mobile skins have been developped fully with AS3 and looking at the default ActionBarSkin, it looks scary :)