I made an application on paint. I want to control the size of brush being used in paint using seek-bar.
In the menu(options) ,I have an option of changing brush size. So, by clicking on it, a seek bar should appear and I should be able to control that using save button (to set) and then use that value inside paint.
How do I do that?
Make seekbar visible inside xml or when you get its reference in onCreate method.
on button click make it visible.
Use latest values by registering OnSeekBarChangeListener on your Seekbar.
Related
This might be one of those forehead-slapping questions, but what I want to do, is make my buttons show orange (xFFFCB447) when they are pressed, just like the Android dialogs do. (picklist for example)
There doesn't seem to be a specific "pressed" TRectangle in the Default Style, and my adding different TRectangles (coloured appropriately doesn't seem to do it either), so my only alternative seems to be to use the Bitmap Style designer to Export the style.png; hope I figure out which part of the image is used for the button pressed before tomorrow afternoon, and Update the image again.
Is there not an easier/quicker way to do it?
Option A) Drop a TRectangle on your button. Set it's Align to Contents. Set it's fill color to Orange. Set it's Opacity to 0.50. Set it's HitTest to False. Set it's Visible to False. In the TButton.OnMouseDown set the TRectangle Visible to True. In the TButton.OnMouseUp set the TRectangle Visible to False. You will also need to set the OnMouseMove of the control that TButton is on to set TRectangle Visible to False as well so if you mouse down and then move away it will be hidden as well.
Option B) Drop a TFillRGBEffect on the TButton. Set it to Orange. Do the same as above to enable and disable the effect on mouse down and up. However, be aware that TFillRGBEffect may be slower than the TRectangle way.
Option C) Just use a TRectangle instead of a TButton. Put a TText or TLabel inside it for the text and align to Contents. Change it's Fill color in OnMouseDown and OnMouseUp.
I've read the API and Googled but perhaps I've missed something: All the visibility options on an ImageButton seem to talk about this view as a whole. So, what should I do if I want to hide the image but keep the background(except for explicitly setting the image to something transparent that is)? I'm doing a Pairs Game and when one clicks on the element it should show the image and if the next click doesn't match the image should be hidden, but the grey background of the button should remain.
Thanks!
So, what should I do if I want to hide the image
Try setting it to #null or create transparent PNG in your drawables and set it.
in XML, remove android:src="something" and in the code remove imgbtn.setImageBitmap(null);
Instead of using ImageButton you can use ImageView with a FrameLayout on top of it. Set the background of FrameLayout as gray color and then show/hide this FrameLayout/Image as per your requirement. Take relative layout for each and make it clickable. On the click event of this layout, do the changes as required.
I want the button to appear as though it has space in between the bottom of it's face and the canvas. Then, when clicked, it will appear as though there is no space between the button and the canvas. I know I can style the button with xml to give it those 2 looks but I don't know how to do the elevated look.
My question is how would one go about doing this?
Easiest approach to this is creating 2 background images, each fitting the state you want, then you can either set the backgrounds according the button's state, or change the backgrounds by setting an onTouchListener to the button.
I am using a button with my own back ground color in android and that button is not getting focus what is the problem?
Buttons normally will not have focus by touch. Also focus depends on the background.
So, check the background - it needs to be of type drawable with multiple states or you need to make a gradient. Check Standard Android Button with a different color
I'm new to Android application development.
I would like to ask the use of image button in Android programming when simple button can also add the image with the button. How can we generate click event of image button?
The Image Button control is a special type of button that displays a Drawable graphic instead of text.
The Image Button and Button controls are both derived from the View class, but
they are unrelated to each other. The Button class is actually a direct subclass
of Text View (think of it as a line of text with a background graphic that looks
like a button), whereas the Image Button class is a direct subclass of Image View.
If you will look in the API for Button you will see that it has a method called setOnClickListener that is inherited from View. Since ImageButton is also a view, you can also call the same method for it.
The only way that I see to use an image in a Button is by using android:background in the XML. This is only used for setting what's shown behind the text of a button. You should use ImageButton when you want to make a button that only uses the image as its defining feature. If you end up wanting to only see the image and have no part of the button background visible, you can set android:background on the button to use an invisible Drawable.