Skip to main content

Posts

Showing posts with the label view

Animate change of view background color in Android

How do you animate the change of background color of a view in Android? For example: I have a view with a red background color. The background color of the view changes to blue. How can I do a smooth transition between colors? If this can't be done with views, an alternative will be welcome.

set the absolute position of a view in Android

Is it possible to set the absolute position of a view in android? (I know that there is an AbsoluteLayout, but it's deprecated...) Lets say I have a screen 240x320px, and I want to put an ImageView which is 20x20px with its center at the position (100,100). What do I have to do? Thanks for the help, this is driving me crazy.

Android animate drop down/up view proper

Okay I'm trying to do a proper slide down animation. The view that slides down should push all views bellow it down in one smooth movement and again when it slides up all the views should follow in one smooth movement. What I've tryed : In code: LinearLayout lin = (LinearLayout)findViewById(R.id.user_list_container); setLayoutAnimSlidedownfromtop(lin, this); lin.addView(getLayoutInflater().inflate(R.layout.user_panel,null),0); And: public static void setLayoutAnimSlidedownfromtop(ViewGroup panel, Context ctx) { AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(100); set.addAnimation(animation); animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f ); animation.setDuration(500); set.addAnim