Toast setGravity - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Toast setGravity method.

This code example shows how to use the following methods: setDuration, setGravity, setView, show
This code example shows how to use the following methods: setDuration, setGravity, setView, show
	 *           the gravity 
	 */ 
	public static void showCustomToast( int viewResId, int duration, int gravity ) {
		View layout = getLayoutInflater().inflate( viewResId, null );
 
		Toast toast = new Toast( mContext.getApplicationContext() );
 
		toast.setGravity( gravity, 0, 0 );
		toast.setDuration( duration );
		toast.setView( layout );
		toast.show();
	} 
	 
	static PorterDuffColorFilter mWhiteMultiplyFilter = new PorterDuffColorFilter( 0xFFFFFFFF, Mode.MULTIPLY );
 
	/** 
	 * Draw folder icon. 
	 *  
	 * @param folder 
	 *           the folder 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getXOffset, getYOffset, setGravity, show
        } 
 
        // inform users of how long the timeout is now 
        final String toast = makeTimeoutToastString(context, screenTimeout);
        mToast = Toast.makeText(context, toast, Toast.LENGTH_LONG);
        mToast.setGravity(Gravity.CENTER, mToast.getXOffset() / 2, mToast.getYOffset() / 2);
        mToast.show();
    } 
 
    @Override 
    protected List<Uri> getObservedUris() {
        return OBSERVED_URIS;
    } 
 
    @Override 
    protected boolean handleLongClick(Context context) {
        Intent intent = new Intent("android.settings.DISPLAY_SETTINGS");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setDuration, setGravity, setView, show
    protected void onBrightnessChanged(final int value, final int max) {
        mText.setText(Integer.toString(Math.round(value * 100.0f / max)) + "%");
        mText.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null);
	int progress = (int) (Math.round(value * 100.0f / max));
	mBrightProg.setProgress(progress);
        mToast.setView(mView);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.setGravity(Gravity.TOP, 0, 0);
        mToast.show();
    } 
 
    @Override 
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case MSG_BRIGHTNESS_CHANGED: {
                onBrightnessChanged(msg.arg1, msg.arg2);
                break; 
            } 
        } 
    } 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setDuration, setGravity, setView, show
    protected void onBrightnessChanged(final int value, final int max) {
        mText.setText(Integer.toString(Math.round(value * 100.0f / max)) + "%");
        mText.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null);
	int progress = (int) (Math.round(value * 100.0f / max));
	mBrightProg.setProgress(progress);
        mToast.setView(mView);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.setGravity(Gravity.TOP, 0, 0);
        mToast.show();
    } 
 
    @Override 
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case MSG_BRIGHTNESS_CHANGED: {
                onBrightnessChanged(msg.arg1, msg.arg2);
                break; 
            } 
        } 
    } 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setDuration, setGravity, show
	} 
	 
	public void toast(String text, int length) {
		mText.setText(text);
 
		mToast.setGravity(Gravity.CENTER, 0, 0);
		mToast.setDuration(length);
		mToast.show();
	} 
 
} 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getXOffset, getYOffset, setGravity, show
        } 
 
        // inform users of how long the timeout is now 
        final String toast = makeTimeoutToastString(context, screenTimeout);
        mToast = Toast.makeText(context, toast, Toast.LENGTH_LONG);
        mToast.setGravity(Gravity.CENTER, mToast.getXOffset() / 2, mToast.getYOffset() / 2);
        mToast.show();
    } 
 
    @Override 
    protected List<Uri> getObservedUris() {
        return OBSERVED_URIS;
    } 
 
    @Override 
    protected boolean handleLongClick(Context context) {
        Intent intent = new Intent("android.settings.DISPLAY_SETTINGS");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setGravity, show
        this.factory = factory;
 
        // Shows the tooltip if it's available. 
        if (getTag() != null) {
            tooltip = Toast.makeText(getContext(), (String) getTag(), Toast.LENGTH_SHORT);
            tooltip.setGravity(Gravity.CENTER, 0, 0);
            tooltip.show();
        } 
        doBegin(); 
    } 
 
    /** 
     * Ends the effect and then executes the runnable after the effect is finished. 
     */ 
    public void end(final Runnable runnableOnODone) {
        doEnd(); 
 
        // Wait till last output callback is done before finishing. 
        if ((lastFilterChangedCallback == null) || lastFilterChangedCallback.done) {
            finish(runnableOnODone);
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Toast setGravity Questions & Answers:

setGravity Method Overview
Set the location at which the notification should appear on the screen.
See Code Examples for other Android Toast Methods: