Example usage for android.view Gravity TOP

List of usage examples for android.view Gravity TOP

Introduction

In this page you can find the example usage for android.view Gravity TOP.

Prototype

int TOP

To view the source code for android.view Gravity TOP.

Click Source Link

Document

Push object to the top of its container, not changing its size.

Usage

From source file:com.orange.ocara.ui.dialog.AudioPlayerDialog.java

@Override
public void onStart() {
    super.onStart();

    // safety check
    if (getDialog() == null)
        return;/* w  w  w . j  av a2s  .c  o m*/

    // set dialog width

    Window window = getDialog().getWindow();

    // set "origin" to top left corner
    window.setGravity(Gravity.TOP); //| Gravity.LEFT);

    int width = getResources().getDimensionPixelSize(R.dimen.audioPlayerDialogWidth);
    window.setLayout(width, WindowManager.LayoutParams.WRAP_CONTENT);

    WindowManager.LayoutParams attributes = window.getAttributes();

    Integer argX = getArguments().getInt("x");
    Integer argY = getArguments().getInt("y");
    if (argX != null && argX >= 0) {
        attributes.x = argX;
    }
    if (argY != null && argY >= 0) {
        attributes.y = argY;
    }

    window.setAttributes(attributes);

}

From source file:am.project.x.business.drawables.cornerdrawable.CornerDrawableActivity.java

@SuppressLint("RtlHardcoded")
@Override//from  w  ww .  j  a  va  2  s.com
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (parent.getId()) {
    case R.id.cnd_sp_direction:
        switch (position) {
        default:
        case 0:
            drawable.setDirection(Gravity.TOP);
            break;
        case 1:
            drawable.setDirection(Gravity.LEFT);
            break;
        case 2:
            drawable.setDirection(Gravity.RIGHT);
            break;
        case 3:
            drawable.setDirection(Gravity.BOTTOM);
            break;
        }
        break;
    case R.id.cnd_sp_location:
        switch (position) {
        default:
        case 0:
            drawable.setLocation(Gravity.CENTER);
            break;
        case 1:
            drawable.setLocation(Gravity.LEFT);
            break;
        case 2:
            drawable.setLocation(Gravity.RIGHT);
            break;
        }
        break;
    }
}

From source file:arun.com.chromer.webheads.ui.views.Trashy.java

@SuppressLint("RtlHardcoded")
private void setInitialLocation() {
    final DisplayMetrics metrics = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(metrics);
    dispWidth = metrics.widthPixels;//from   w  w  w. j a v a2  s  .c om
    dispHeight = metrics.heightPixels;

    createWindowParams();

    windowParams.gravity = Gravity.LEFT | Gravity.TOP;
    int offset = getAdaptWidth() / 2;
    windowParams.x = (dispWidth / 2) - offset;
    windowParams.y = dispHeight - (dispHeight / 6) - offset;
}

From source file:com.acious.android.paginationseekbar.internal.PopupIndicator.java

public void showIndicator(View parent, Rect touchBounds) {
    if (isShowing()) {
        mPopupView.mMarker.animateOpen();
        return;/*from   w w w. j  a v  a 2 s  .  com*/
    }

    IBinder windowToken = parent.getWindowToken();
    if (windowToken != null) {
        WindowManager.LayoutParams p = createPopupLayout(windowToken);

        p.gravity = Gravity.TOP | GravityCompat.START;
        updateLayoutParamsForPosiion(parent, p, touchBounds.bottom);
        mShowing = true;

        translateViewIntoPosition(touchBounds.centerX());
        invokePopup(p);
    }
}

From source file:com.fastaccess.tfl.ui.widget.drag.DragView.java

public void show(IBinder windowToken, int touchX, int touchY) {
    WindowManager.LayoutParams lp;//from  w  w w .  java  2 s . c  o m
    int pixelFormat;
    pixelFormat = PixelFormat.TRANSLUCENT;
    lp = new WindowManager.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, touchX - mRegistrationX, touchY - mRegistrationY,
            WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
            pixelFormat);
    lp.gravity = GravityCompat.START | Gravity.TOP;
    lp.token = windowToken;
    lp.setTitle("DragView");
    mLayoutParams = lp;
    mWindowManager.addView(this, lp);
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToGroupObj.java

@Override
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from w  w  w .ja v a  2s . co  m*/

    TextView valueTV = new TextView(context);
    valueTV.setText("Join me in '" + content.optString(GROUP_NAME) + "'");
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
    frame.addView(valueTV);
}

From source file:com.linkbubble.ui.BubbleFlowActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    mDestroyed = false;/*from   w w w.  java  2 s .com*/
    super.onCreate(savedInstanceState);

    Settings settings = Settings.get();
    if (null != settings) {
        setTheme(settings.getDarkThemeEnabled() ? R.style.ThemeTransparentDark : R.style.ThemeTransparent);
    }
    Log.d("TAG", "!!!!! ON CREATE");
    mContentViews = new ArrayList<>();
    mPreClosedContentViews = new ArrayList<>();
    setVisible(false);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.activity_bubble_flow);

    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTIVITY_INTENT_NAME);
    LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this);
    bm.registerReceiver(mBroadcastReceiver, filter);
    MainController controller = getMainController();
    if (null != controller && null != controller.mBubbleFlowDraggable) {
        synchronized (MainApplication.mActivitySharedLock) {
            MainApplication.mActivitySharedLock.notify();
        }
        if (MainApplication.mMoveWebViewsActivityToBack) {
            moveTaskToBack(true);
        }
    } else {
        moveTaskToBack(true);
        mDestroyed = true;
        finish();
        startActivityForResult(new Intent(this, EntryActivity.class), 0);
    }
    int canvasMaskHeight = getResources().getDimensionPixelSize(R.dimen.canvas_mask_height);
    mTopMaskView = new ImageView(this);
    mTopMaskView.setImageResource(R.drawable.masked_background_half);
    mTopMaskView.setScaleType(ImageView.ScaleType.FIT_XY);
    FrameLayout.LayoutParams topMaskLP = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            canvasMaskHeight);
    topMaskLP.gravity = Gravity.TOP;
    mTopMaskView.setLayoutParams(topMaskLP);
    addContentView(mTopMaskView, topMaskLP);
}

From source file:cn.djangoogle.pull2load.internal.LoadingLayout.java

public LoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
    super(context);
    mMode = mode;/*from   w w  w .  j  a  v a  2 s  . c o m*/
    mScrollDirection = scrollDirection;

    switch (scrollDirection) {
    case HORIZONTAL:
        LayoutInflater.from(context).inflate(R.layout.pull2load_header_horizontal, this);
        break;
    case VERTICAL:
    default:
        LayoutInflater.from(context).inflate(R.layout.pull2load_header_vertical, this);
        break;
    }

    mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner);
    mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text);
    mHeaderProgressWheel = (ProgressWheel) mInnerLayout.findViewById(R.id.pull_to_refresh_progress_wheel);
    mSubHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_sub_text);
    mHeaderImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_image);

    LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams();

    switch (mode) {
    case PULL_FROM_END:
        lp.gravity = scrollDirection == Orientation.VERTICAL ? Gravity.TOP : Gravity.LEFT;

        // Load in labels
        mPullLabel = context.getString(R.string.pull_to_refresh_from_bottom_pull_label);
        mRefreshingLabel = context.getString(R.string.pull_to_refresh_from_bottom_refreshing_label);
        mReleaseLabel = context.getString(R.string.pull_to_refresh_from_bottom_release_label);
        break;

    case PULL_FROM_START:
    default:
        lp.gravity = scrollDirection == Orientation.VERTICAL ? Gravity.BOTTOM : Gravity.RIGHT;

        // Load in labels
        mPullLabel = context.getString(R.string.pull_to_refresh_pull_label);
        mRefreshingLabel = context.getString(R.string.pull_to_refresh_refreshing_label);
        mReleaseLabel = context.getString(R.string.pull_to_refresh_release_label);
        break;
    }

    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
        Drawable background = attrs.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
        if (null != background) {
            ViewCompat.setBackground(this, background);
        }
    }

    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance)) {
        TypedValue styleID = new TypedValue();
        attrs.getValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance, styleID);
        setTextAppearance(styleID.data);
    }
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance)) {
        TypedValue styleID = new TypedValue();
        attrs.getValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance, styleID);
        setSubTextAppearance(styleID.data);
    }

    // Text Color attrs need to be set after TextAppearance attrs
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextColor)) {
        ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderTextColor);
        if (null != colors) {
            setTextColor(colors);
        }
    }
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderSubTextColor)) {
        ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderSubTextColor);
        if (null != colors) {
            setSubTextColor(colors);
        }
    }

    // Try and get defined drawable from Attrs
    Drawable imageDrawable = null;
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawable)) {
        imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawable);
    }

    // Check Specific Drawable from Attrs, these overrite the generic
    // drawable attr above
    switch (mode) {
    case PULL_FROM_START:
    default:
        if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableStart)) {
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableStart);
        } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableTop)) {
            Pull2LoadCommonUtil.warnDeprecation("ptrDrawableTop", "ptrDrawableStart");
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableTop);
        }
        break;

    case PULL_FROM_END:
        if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableEnd)) {
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableEnd);
        } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableBottom)) {
            Pull2LoadCommonUtil.warnDeprecation("ptrDrawableBottom", "ptrDrawableEnd");
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableBottom);
        }
        break;
    }

    // If we don't have a user defined drawable, load the default
    if (null == imageDrawable) {
        imageDrawable = ContextCompat.getDrawable(context, getDefaultDrawableResId());
    }

    // Set Drawable, and save width/height
    setLoadingDrawable(imageDrawable);

    reset();
}

From source file:com.hezaijin.advance.widgets.view.progress.internal.PopupIndicator.java

public void showIndicator(View parent, Rect touchBounds) {
    if (isShowing()) {
        mPopupView.mMarker.animateOpen();
        return;//  w  w w  .j  av a  2  s  . co m
    }

    IBinder windowToken = parent.getWindowToken();
    if (windowToken != null) {
        WindowManager.LayoutParams p = createPopupLayout(windowToken);
        p.gravity = Gravity.TOP | GravityCompat.START;
        updateLayoutParamsForPosiion(parent, p, touchBounds.bottom);
        mShowing = true;

        translateViewIntoPosition(touchBounds.centerX());
        invokePopup(p);
    }
}

From source file:biz.easymenu.easymenung.LoginFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = li.inflate(R.layout.logindialog, container, false);

    WindowManager.LayoutParams WMLP = this.getDialog().getWindow().getAttributes();

    adultsNb = (NumberPicker) v.findViewById(R.id.adultnumpick);
    childrenNb = (NumberPicker) v.findViewById(R.id.childrennumpick);
    etPass = (EditText) v.findViewById(R.id.loginPass);

    pbar = (ProgressBar) v.findViewById(R.id.pBarLogin);

    btnOk = (Button) v.findViewById(R.id.lgnbtnOK);
    btnCancel = (Button) v.findViewById(R.id.lgnbtnCancel);
    btnDiners = (Button) v.findViewById(R.id.lgndinersbtnOK);

    btnDiners.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w w w  .  jav  a  2  s  . co  m*/
        public void onClick(View v) {

            new Thread(new DinersRun()).start();
        }
    });

    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            pbar.setVisibility(View.VISIBLE);
            new Thread(new NewSessionRun()).start();
        }
    });

    btnCancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            dismiss();
        }
    });

    WMLP.y = 100; //y position
    WMLP.gravity = Gravity.TOP;
    WMLP.windowAnimations = R.style.PauseDialogAnimation;
    this.getDialog().getWindow().setAttributes(WMLP);
    this.getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    //this.getDialog().getWindow().getAttributes().windowAnimations = R.style.PauseDialogAnimation;
    spin = (AutoCompleteTextView) v.findViewById(R.id.spinnerLogin);

    adapter = new ArrayAdapter<String>(getActivity(), R.layout.autocompleteview, items);

    spin.setAdapter(adapter);

    spin.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (count == 1 && start == 0) {
                pbar.setVisibility(View.VISIBLE);
                new Thread(new LoadItemsRun()).start();
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

        }

        public void afterTextChanged(Editable s) {

        }
    });

    return v;
}