`
Hi,
I have requirement of using my own background and blue light for toggle button.
However, using this i am not able to custom position light of toggle button which is always placed to the bottom of button.
I want to move it above and just below center of button.
I tried with paddingBottom but that did not help. Any help regarding this appreciated.
-Thanks,
Manju
That light is part of the nine-patch png. If you create new backgrounds, you need to add your own "on" and "off" circles to the file. You then use the border lines of the nine-patch to prevent stretching of the circle.
http://developer.android.com/guide/developing/tools/draw9patch.html
Read also my answer here for another explanation: How to create android spinner without down triangle on the right side of the widget
Use a LayerList and position the graphic on the toggle button by enclosing the drawable in a bitmap tag, and set its gravity to 'center' - see LayerList here
Use a relativeLayout and do android:layout_Below, if I understand your question correctly
Related
I've spent way too much time researching this, but I'm wondering if anyone can provide any insight to how Android does its spinner styling with the triangle dropdown indicator?
The reason I want to know is that I am using a custom textview as spinner item, and once I use that I lose the triangle. In addition, I want to make the triangle white.
I've seen previous answers with modifying the theme but I don't want all spinners to change so I don't want to modify the entire theme. I want to learn how Android does the triangle so I can recreate it. I tried using a list-layout drawable with a triangle shape but I'm wondering if there is a better way?
You can set drawbleEnd
android:drawableEnd="#drawable/imgresource"
create an image of how you want as your spinners background with whatever type or triangle and whichever color your want and then set that image as the background of your textview like this
android:background="#drawable/myBackground"
It a simple Nine Patch Drawable.
You can create a NinePatch graphic, set a black dot on the top and left to expand the top and left edges. With a triangle in the bottom right.
How to Add triangle shape for activity or page change like in facebook page?
You can use QuickAction Dialog in android Here is example code .
If you are considered about the shape
See this answer
Also this article
And simple work around ::Give your parent layout transparent background and place the triangle in center of layout and you can achieve the position in the image
Or you can go for 9 patch images directly :: see this
how to add the text "on" & "off" for the toggle button ?
Do we need to add text also in image ?
You have a few options.
Make your graphic larger and include the text.
Use a LinearLayout and incorporate two TextViews around your ImageView.
Subclass your overall view and draw the text in onDraw().
If you are using XML to generate the toggle button you would use android:textOn and android:textOff in your ToggleButton<>
Source:
http://developer.android.com/reference/android/widget/ToggleButton.html#attr_android:textOn
In this picture you can see (barely lol) that the spinner icons that rest on the bottom and bottom right are very hard to see due to the black background that I am using. What would I need to do to make that greyish looking color to white or any color for that matter?
Try this tutorial:
Android Custom Spinners
A similar process is used for working with custom buttons and other elements.
Updated as the link is broken. Try this stackoverflow answer
Spinner Background Design
In android is there anything thing like we can create a hidden button or image and it is still clickable.or alternately is there any way to achieve this functionality in Android.
In ios we have the benefit of placing a clickable hidden button.
Everything can be achieved in Android
<Button...
android:background="#null">
You can make the button transparent or translucent by using the background property:
android:background="#ARGB"
where A is the transparency, which can be set between 0-F i.e., 0 means transparent and F means opaque.
The remaining colours are R-Red, G-Green, B-Blue.
so an eg. might be:
android:background="#200B"
which gives a tinge of blue colour.
This way you can provide transparency as well as a tinge of transparent colour to your view.
This works with any view.
Also you can apply this through code:
button.setBackgroundColour(0x220000BB);
Probably use a transparent Image to the button.