Why doesn't EditText get focus with setFillAfter(true)? - java

So when you have the visibility set to INVISIBLE on the EditText fields it doesn't want to get focus for the keyboard.
I fixed this issue by changing the visibility on those fields after the animation completes like this:
edit_text.setVisibility(View.INVISIBLE);
final Animation fadeInAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in_view);
fadeInAnimation.setFillAfter(true);
edit_text.startAnimation(fadeInAnimation);
edit_text.setVisibility(View.VISIBLE);
But I want to know why it doesn't get focus. Shouldn't setFillAfter(true) set them to visible again?

The description for setFillAfter(boolean fillAfter) says
If fillAfter is true, the
transformation that this animation
performed will persist when it is
finished.
When set to true it does do this
An animation on Android does not actually animate the View itself, it
animates a bitmap representation of the View
Check out: Animation.setFillAfter/Before - Do they work/What are they for?

Related

Is there a way to disable MotionLayout visiblity changes animation?

In my MotionScene I have transition which lasts for several seconds. In ConstraintSet I have a view that is invisible that I want to make visible when the transition is done. But I don't want to animate the view going from Visibility.GONE to Visibility.VISIBLE. Is there a way to stop that?
If needed I can provide code, but it's not that complex. It's just a transition with two ConstraintSet-s, this View is in both sets in starting set it's visibility="visible", and in ending set it's visibility = "gone"
Does anybody have any suggestions?
EDIT: I should note that I did put
android:animateLayoutChanges="false" in root layout of the activity that uses this MotionScene.
If i understand your problem, you can use alpha animation like this;
AlphaAnimation animation1 = new AlphaAnimation(1f, 0.3f);
animation1.setDuration(1000);
animation1.setFillAfter(true);
yourView.startAnimation(animation1);

Android Studio: ListView OnClick animation doesn't work if you set background color of items

In my project I've setted the background color of my items (composed of several elements inserted in a ConstraintLayout) inside a ListView but the default animation of click and long click disappears if the background color is not at least a little transparent. In fact, as transparency decreases, the effect of clicking on the elements is less and less evident. In a few words, color goes to hide the animation if isn't transparent. How to solve this problem and then bring selection animation to the foreground?
Same problem, still unresolved: ListView items not showing tap animation
RESOLVED!
You have to simply add android:drawSelectorOnTop="true" in your ListView XML tag. In this way you can modify and customize the list item background and at the same time bring back the "selector" on top of the "z axis" of GUI. Yuhu!
If you are giving a background coloraturas to the list items then you might be hiding the system press animations. in this case you can use the methods like OnItemLongClickListener() and itemClickListener () and add your custom animations to the view.

How can I set on the screen, the 'onClick' method 'setSoundEffectEnabled(false)'?

My ConstraintLayout has an OnClick method, so every time the screen is touched, i works like a button. But the problem here is that I need to get rid of the default sound button but the setSoundEffectEnabled(false)' ONLY works for actual button views.
Any ideas?

Android change in view - Button state gets reset

I have a button which is basically used for start/stop. So initially the text of the button is set to start. I attached a OnClickListener to it. So whenever it gets clicked i change its text. So if it was start it become stop and vice-versa.
The problem comes when i change my phone view from portrait to landscape or vice-versa the button text gets reset.
So for example I clicked the start button---it changed to stop. Now if I tilt my phone to change the view the button text gets set to start again.
Am I using the button in a wrong way?
You should save your button state. When screen orientation changes, onCreate is called and all your app variables are re-intitialized. Read more here http://developer.android.com/reference/android/app/Activity.html
No, you are using the button in the right way.
The thing what you are seeing is "configuration change". When you are tilting your device, Android recreating your activity and recreating all it's views (so, they getting default captions as them described in XML).
You need to do the
disable configuration changes for your Activity. To do so, add the following to your manifest's activity tag: android:configChanges="orientation|keyboardHidden". It is not suitable, if you have different layouts for landscape and portraint orientations, when you need to...
handle the configuration changes by overriding onSaveInsatnceState method of your Activity, save a state there and then use it in onCreate method.
See this article for further explanation

Can I show up the textbox editor on an image icon in Android?

all,
We know on Andorid, for a EditText, by default, whenever the EditText is clicked, the soft keyboard pops up to let you enter text. When you click DONE, it closes out and put the text directly to the EditText.
Now, what I am trying to do is, instead of an EditText, I have an ImageView which is to let user enter some comment.(So the ImageView actually is an comment icon). I wish whenever the icon is clicked, it pops up the text editor with user previous entered text, again once the DONE is hit, it closes out and I can save whatever text there back to a string member of the Activity. Is that possible?
So far, all I've seen about InputMethodManager is on EditText control, If it is too complicated, I probably just put an EditText into a sperate Activity.
Thanks.
There are many solutions:
One is to use custom dialog: http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
Second one is to use a transparent activity on top of that one.
Then you could use FrameLayout and insert another view in an exact position...
I think you should try the frist or second one. Every ImageView can be easily converted into a button by adding onClick event to it.

Categories

Resources