Code example for ImageButton

Methods: getBackgroundsetImageResource

0
	 */ 
	void moveTo(int tabIndex) {
		updateLayoutDimensions(); 
		final BackgroundImage bgImg = (BackgroundImage)getChildTabViewAt(tabIndex);
		if (bgImg != null && tabIndex != mSelectedTab) {
			mSlider.setImageResource(bgImg.getSliderIconResource());
			snapTo(bgImg.getTabIndex());
			setCurrentTab(bgImg.getTabIndex());
		} 
	} 
	 
	/** 
	 * Moves the slider to a position 
	 * @param pos Absolute position of outer-left edge of the slider (0 = left aligned) 
	 */ 
	private void moveSlider(int pos) {
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
		params.setMargins(pos, 0, 0, 0);
		mSlider.setLayoutParams(params);
	} 
	 
	/** 
	 * Moves the background to a position. Won't move if all icons already visible. 
	 * @param pos Relative position of all background icons. 
	 */ 
	private void moveBackground(int pos) {
		// only move background if there are more icons than visible 
		if (pos != 0 && mBackMoveFactor > 0) {
			mInverseSliderBackground.offsetLeftAndRight(pos);
			mInverseSliderBackground.invalidate();
		} 
	} 
 
	 
	/** 
	 * Moves the slider (and the background) to the correct position. Note that 
	 * the actual content switch is not done in here and must be manually called: 
	 * <pre>mSelectionChangedListener.onTabSelectionChanged(mCurrTabIndex, true);</pre> 
	 * @param tabIndex Tab index (first tab = 0) 
	 */ 
	private void snapTo(int tabIndex) {
		if (mBackMoveFactor > 0) { // background scrolls
			final float snapWidth; 
			if (mNumTabs > 1) {
				snapWidth = (float)mSliderMoveWidth / (float)(mNumTabs - 1);
			} else { 
				snapWidth = mSliderMoveWidth;
			} 
			final int snapPos = Math.round(tabIndex * snapWidth);
			final int backSnapPos =  -(int)Math.round((snapPos * mBackMoveFactor));
//			Log.i("snap", "Snapping to " + index + "(" + snapPos + " / " + backSnapPos + ")"); 
			mSnapAnimation.init(snapPos, backSnapPos);
		} else { // background doesn't scroll 
			final BackgroundImage bgImg = (BackgroundImage)mInverseSliderBackground.getChildAt(tabIndex);
			final int snapPos = bgImg.getCenteredPosition() - Math.round((float)mSlider.getBackground().getIntrinsicWidth() / 2.0f) + SHADOW_PADDING;
			mSnapAnimation.init(snapPos, SnapAnimation.NO_ANIMATION);
		} 
		mSnapAnimation.setDuration(100);
		mSlider.startAnimation(mSnapAnimation);
	} 
	 
	/** 
	 * Updates layout dimensions. This should be done only once, though I  
	 * haven't found out yet how. Should be called when the layout is rendered. 
	 */ 
	private void updateLayoutDimensions() { 
		if (mSliderMoveWidth == 0) {
			mSliderMoveWidth = mOuterLayout.getWidth() - mSlider.getBackground().getIntrinsicWidth() + (2 * SHADOW_PADDING);
		} 
		if (mBackMoveWidth == 0) {
			mBackMoveWidth = mInverseSliderWidth - mOuterLayout.getWidth() + mOuterLayout.getPaddingRight() + mOuterLayout.getPaddingLeft();// - (2 * SHADOW_PADDING);
		} 
		if (mBackMoveFactor == 0) {
Connect your IDE to all the code out there  Get Codota for Java