Code example for RelativeLayout

Methods: setBackgroundDrawable, startAnimation

0
	    v.setLayoutParams(bgParams);
    } 
     
    protected void setBackground(int imageID)
    { 
    	Drawable background = appUtil.getDrawableClipFromCenter(mLayout, imageID, width, height);
         
        mLayout.setBackgroundDrawable(background);
    } 
     
    private void applyAnimation(Animation _out, Animation _in) 
    { 
    	final Animation in = _in;
     
    	// Ensure the text stays out of screen when the slide-out 
    	// animation has completed. 
    	_out.setFillAfter(false);
    	 
    	// Create a listener to wait for the slide-out animation to complete. 
    	_out.setAnimationListener(new AnimationListener() 
	    	{ 
		    	public void onAnimationEnd(Animation _animation) 
		    	{ 
		            setBackground(R.drawable.resources_fondos_landscape_off); 
		             
		            String image = appUtil.getRandomQuestionImage(0);
		             
		    		bgButtonLeft.setBackgroundResource(appUtil.getDrawableID(image));
		    		 
		    		// Slide it back in to view 
			    	mLayout.startAnimation(in);
		    	} 
		    	public void onAnimationRepeat(Animation _animation) {}
		    	public void onAnimationStart(Animation _animation) {}
	    	}); 
    	 
		// Apply the slide-out animation 
		mLayout.startAnimation(_out);
		 
		if( width > height )
			setBackground(R.drawable.resources_fondos_landscape); 
		else 
			setBackground(R.drawable.resources_fondos_portrait); 
Contextual code suggestions in your IDE  Get Codota for Java