Android ImageButton - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ImageButton class.

This code example shows how to use the following methods:getBackground, getHeight, getPaddingBottom, getPaddingTop, getTop
                + mPause.getPaddingTop() + mPause.getPaddingBottom(),
                mPause.getBackground().getMinimumHeight());
        int prevHeight = Math.max(mPrev.getDrawable().getIntrinsicHeight() + mPrev.getPaddingTop()
                + mPrev.getPaddingBottom(),
                mPrev.getBackground().getMinimumHeight());
        int nextHeight = Math.max(mNext.getDrawable().getIntrinsicHeight() + mNext.getPaddingTop()
                + mNext.getPaddingBottom(),
                mNext.getBackground().getMinimumHeight());
        assertEquals("Layout incorrect height", pauseHeight, mLayout.getHeight()); 
        assertEquals("Pause incorrect height", pauseHeight, mPause.getHeight()); 
        assertEquals("Prev incorrect height", prevHeight, mPrev.getHeight()); 
        assertEquals("Next incorrect height", nextHeight, mNext.getHeight()); 
        assertEquals("Pause wrong top", 0, mPause.getTop()); 
        assertEquals("Prev wrong top", (pauseHeight - prevHeight) / 2, mPrev.getTop());
        assertEquals("Next wrong top", (pauseHeight - nextHeight) / 2, mNext.getTop());
        assertEquals("CurrentTime wrong bottom",  pauseHeight, mCurrentTime.getBottom());
        assertEquals("TotalTime wrong bottom",  pauseHeight, mTotalTime.getBottom());
        assertTrue("CurrentTime too tall", mCurrentTime.getTop() > 0);
        assertTrue("TotalTime too tall", mTotalTime.getTop() > 0);
    } 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setOnClickListener
	 * @see AbstractViewFactory.create. 
	 */ 
	@Override 
	public Widget create(Activity activity, final int handle)
	{ 
		ImageButton b = new ImageButton( activity );
		b.setOnClickListener( new MoSyncSendOnClick( handle ) );
 
		return new ImageButtonWidget( handle, b );
	} 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setOnClickListener, setImageResource
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
         
        RelativeLayout container = new RelativeLayout(this);
         
        ImageButton button = new ImageButton(this);
        button.setImageResource(getIntent().getIntExtra("moodimg", 0));
        button.setOnClickListener(this);
         
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);
         
        container.addView(button, lp);
         
        setContentView(container);
    } 
 
    public void onClick(View v) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setOnClickListener, setPadding, setImageResource
		LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.WRAP_CONTENT);
 
		l.setLayoutParams(params);
 
		b = new ImageButton(context);
		b.setLayoutParams(params);
		b.setOnClickListener(new OnClickListener() {
			@Override 
			public void onClick(View v) {
				ImageButtonModifier.this.onClick();
			} 
		}); 
		b.setImageResource(myText);
 
		if (getTheme() != null) 
			getTheme().applyNormal1(b);
 
		int p = 6;
		b.setPadding(p, p, p, p);

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBackground, getHeight, getPaddingBottom, getPaddingTop, getTop
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBackground, setImageResource
		final int hPadding = Math.round((float)(mSeparationWidth - drawableWidth) / 2.0f);
		final int vPadding = Math.round((float)((int)(SCROLLBAR_HEIGHT * sScale) - drawableHeight) / 2.0f); 
		 
		bgImg.setOverlayIconResource(newTab.getBigIconResource());
		 
		final int sliderWidth = mSlider.getBackground().getIntrinsicWidth() - 2 * SHADOW_PADDING;
		final int borderVPadding = (int) Math.floor((float)(sliderWidth - drawableWidth) / 2.0f);
		 
		if (mNumTabs == 0) {
			bgImg.setPadding(borderVPadding, vPadding, hPadding, 0);
			mSlider.setImageResource(newTab.getActiveIconResource());
			mInverseSliderWidth += (borderVPadding + drawableWidth + hPadding);
		} else { 
			if (mNumTabs > 1) {
				BackgroundImage lastTab = (BackgroundImage)mInverseSliderBackground.getChildAt(mNumTabs - 1);
				mInverseSliderWidth += (lastTab.getPaddingLeft() - lastTab.getPaddingRight());
				lastTab.setPadding(lastTab.getPaddingLeft(), lastTab.getPaddingTop(), lastTab.getPaddingLeft(), 0);
			} 
			mInverseSliderWidth += (hPadding + drawableWidth + borderVPadding);
			bgImg.setPadding(hPadding, vPadding, borderVPadding, 0);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setBackgroundColor, setOnClickListener, setTag, setImageDrawable
    } 
     
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) {
        IAchivement item = (IAchivement)getItem(position);
        ImageButton imageButton = new ImageButton(this.getContext());
        imageButton.setTag(item.getKey());
        int id = item.isUnlocked() ? item.getBadge() : item.getLockedBadge();
        Drawable drawable = this.getContext().getResources().getDrawable(id);
        imageButton.setImageDrawable(drawable);
        imageButton.setBackgroundColor(Color.TRANSPARENT);
        if (item.isUnlocked())
        { 
            imageButton.setOnClickListener(this);
        } 
        convertView = imageButton;
        return convertView;
    } 
     
    public void onClick(View v)
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLayoutParams, setLayoutParams, setOnTouchListener, setColorFilter, setVisibility
		setBoundaryPointParameters(endPointImageButton, leftMargin);
	} 
 
	private void setBoundaryPointParameters(ImageButton boundaryPoint, int leftMargin) {
		int pixelPerSecond = SoundMixer.getInstance().getPixelPerSecond();
		RelativeLayout.LayoutParams layout = (LayoutParams) boundaryPoint.getLayoutParams();
		layout.height = getHeight();
		layout.width = pixelPerSecond;
		layout.setMargins(leftMargin, 0, 0, 0);
		boundaryPoint.setColorFilter(Color.BLACK);
		boundaryPoint.setVisibility(VISIBLE);
		boundaryPoint.setLayoutParams(layout);
		boundaryPoint.setOnTouchListener(onTimelineTouchListener);
	} 
 
	public void resetTimeline() { 
		Iterator<Entry<Integer, TimelineTrackPosition>> it = trackPositions.entrySet().iterator();
 
		while (it.hasNext()) {
			HashMap.Entry<Integer, TimelineTrackPosition> pairs = it.next();
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLayoutParams
This code example shows how to use the following methods:setOnClickListener, setImageResource, setVisibility

Related Android ImageButton Questions & Answers:

Other Android ImageButton Examples

15:	public class MainActivity extends Activity {
16:	
17:		ImageButton btnSwitch;
18:	
19:		private Camera camera;
-
29:	
30:			// flash switch button
31:			btnSwitch = (ImageButton) findViewById(R.id.btnSwitch);
32:	
33:	}

Read More

19:	
20:		private ImageButton btnPlay;
21:		private ImageButton btnForward;
22:		private ImageButton btnBackward;
23:		private ImageButton btnNext;
-
20:		private ImageButton btnPlay;
21:		private ImageButton btnForward;
22:		private ImageButton btnBackward;
23:		private ImageButton btnNext;
24:		private ImageButton btnPrevious;
-
21:		private ImageButton btnForward;
22:		private ImageButton btnBackward;
23:		private ImageButton btnNext;
24:		private ImageButton btnPrevious;
25:		private ImageButton btnPlaylist;
-
22:		private ImageButton btnBackward;
23:		private ImageButton btnNext;
24:		private ImageButton btnPrevious;
25:		private ImageButton btnPlaylist;
26:		private ImageButton btnRepeat;
-
23:		private ImageButton btnNext;
24:		private ImageButton btnPrevious;
25:		private ImageButton btnPlaylist;
26:		private ImageButton btnRepeat;
27:		private ImageButton btnShuffle;
-
24:		private ImageButton btnPrevious;
25:		private ImageButton btnPlaylist;
26:		private ImageButton btnRepeat;
27:		private ImageButton btnShuffle;
28:		private SeekBar songProgressBar;
-
25:		private ImageButton btnPlaylist;
26:		private ImageButton btnRepeat;
27:		private ImageButton btnShuffle;
28:		private SeekBar songProgressBar;
29:		private TextView songTitleLabel;
-
26:		private ImageButton btnRepeat;
27:		private ImageButton btnShuffle;
28:		private SeekBar songProgressBar;
29:		private TextView songTitleLabel;
30:		private TextView songCurrentDurationLabel;
-
50:			// All player buttons
51:			btnPlay = (ImageButton) findViewById(R.id.btnPlay);
52:			btnForward = (ImageButton) findViewById(R.id.btnForward);
53:			btnBackward = (ImageButton) findViewById(R.id.btnBackward);
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
-
51:			btnPlay = (ImageButton) findViewById(R.id.btnPlay);
52:			btnForward = (ImageButton) findViewById(R.id.btnForward);
53:			btnBackward = (ImageButton) findViewById(R.id.btnBackward);
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
-
52:			btnForward = (ImageButton) findViewById(R.id.btnForward);
53:			btnBackward = (ImageButton) findViewById(R.id.btnBackward);
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
-
53:			btnBackward = (ImageButton) findViewById(R.id.btnBackward);
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
-
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
-
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
59:			songProgressBar = (SeekBar) findViewById(R.id.songProgressBar);
-
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
59:			songProgressBar = (SeekBar) findViewById(R.id.songProgressBar);
60:			songTitleLabel = (TextView) findViewById(R.id.songTitle);
-
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
59:			songProgressBar = (SeekBar) findViewById(R.id.songProgressBar);
60:			songTitleLabel = (TextView) findViewById(R.id.songTitle);
61:			songCurrentDurationLabel = (TextView) findViewById(R.id.songCurrentDurationLabel);

Read More

15:	public class MainActivity extends Activity {
16:	
17:		ImageButton btnSwitch;
18:	
19:		private Camera camera;

Read More

See Code Examples for Android ImageButton Methods: