Android SetEnable has an obscured view - android

I use setEnabled on RadioGroups, EditText, Spinner, and Checkbox. However when I do so the data is very dark to see (have to squint at it). How do I make it so that the disabled controls can be viewed easily by the user AND have it differentiated from the editable mode controls.

You would have to provide the drawables for the background of each control. You'd probably want to implement a selector to change the image based on the state.

Related

Easy way to change Firemonkey button pressed color on Android

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.

Android Widgets with Custom backgrounds not getting Focus

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

'Unset' Button background

I'm changing the background drawable for my buttons when they're clicked (as they trigger functions such as play/record). While playing/recording, the button glows (a different 9-patch is set as the background) and turns into a stop button. My problem is that currently I'm using:
b.setBackgroundResource(R.drawable.btn_default_normal);
to set the background back again afterwards. This works, but the normal behaviour when I use setEnabled(false) is lost. After a button has been used, and reset to normal, it retains the normal background (rather than the dimmed one) when disabled. The text still changes colour though. Is there a way of 'resetting' the background of the button to default, so that it retains its normal behaviour?
Ok, I got the answer from this blog post in the end. What you have to do is create an xml document with all the different button states, and assign that rather than just an image to the background.

Losing screen object auto-focus

I have a GridView displaying buttons to different screens of my app. When this grid screen, the first cell is selected. Is there a way to programmatically have no cells selected when the screen launches? Or do I have to hide the selector?
When this grid screen, the first cell is selected.
That should only be true if the user was using the navigator (D-pad, trackball, etc.) in the previous activity.
Is there a way to programmatically have no cells selected when the screen launches?
Generally, the user determines this based on whether they are in touch mode or not. You could try setSelection(-1) or something, but I would not be surprised if this fails to work.
Or do I have to hide the selector?
I would recommend just following the platform conventions. If the user is using the D-pad or trackball, they probably want to use the D-pad or trackball, and disabling the selector will simply make them frustrated with you and your app. Please see the article I linked to above for more details on touch mode and why it works the way it does.

Android Soft Keyboard: How to manipulate views on keyboard on/off

I have a layout which has one large EditText view at the top + a bunch of buttons at the bottom. The EditText is made to shrink and expand when the ime is activated/deactivated by using adjust_resize. The buttons at the bottom are pushed up above the ime.
I would like to hide these buttons when the ime displays, to provide enough space for the EditText view.
I have so far tried the following:
subclassed EditText and provided the activity the option to register a callback on the view's OnSizeChanged.
Used this callback to change the visibility of the buttons (actually the layout container) to GONE.
This work OK and does hide the buttons when the ime pops up.
However, the EditText does not expand into the new available space.
Furthermore, when the ime is disposed off, the EditText field is now bigger than it was originally, pushing (the now showing) buttons outside the screen.
I should also add that when typing the first letter into the view, and the ime displays the word options, the screen is redrawn and the EditText fills the vacant space.
Any ideas on how to get this to work?
Or even better, is there a simpler solution to my requirement?
Thanks...
NB: In my view, scrolling is not a good option.
I got this to work by changing the above method a bit:
Wrapped the entire layout with a FrameLayout
subclassed the FrameLayout and provided the activity the option to register a callback on the layout's OnMeasure
This gives the activity a chance to change visibility of views before these are measured.
I would still be very happy to hear about simpler solutions, especially in regards to figuring out whether the keyboard is currently visible or not.
(dumpsys window shows this information. Can we easily get to it?)
Have you tried to call myView.invalidade() ?
I was using the GONE property, but then changed to button.setVisibility(View.INVISIBLE); because I don't have any other stuff on my screen.
on the adjust_resize, you will need to check again when the keyboard has gone and show the buttons again.

Categories

Resources