List of usage examples for android.view Gravity TOP
int TOP
To view the source code for android.view Gravity TOP.
Click Source Link
From source file:com.example.mapsv2.ClustersAreListsActivity.java
private void showInfo(final int x, int y, final Cluster cluster) { final int orientation = getResources().getConfiguration().orientation; // (re-)Load cluster data into the ListView @SuppressWarnings("unchecked") ArrayAdapter<String> adapter = (ArrayAdapter<String>) listView.getAdapter(); adapter.clear();//from w w w . j a v a 2 s . c o m for (Marker m : cluster.markers) { adapter.add(m.getTitle()); } adapter.notifyDataSetChanged(); // Reconfigure the layout params to position the info window on screen FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) infoWindow.getLayoutParams(); if (orientation == Configuration.ORIENTATION_PORTRAIT) { lp.topMargin = y; lp.leftMargin = defaultMargin; lp.rightMargin = defaultMargin; lp.width = LayoutParams.MATCH_PARENT; lp.height = LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.LEFT | Gravity.TOP; infoWindow.setBackgroundResource(R.drawable.info_window_bg_up); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { lp.leftMargin = x + defaultMargin; lp.topMargin = defaultMargin; lp.bottomMargin = defaultMargin; lp.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; lp.width = LayoutParams.WRAP_CONTENT; lp.height = LayoutParams.WRAP_CONTENT; infoWindow.setBackgroundResource(R.drawable.info_window_bg_left); } infoWindow.setLayoutParams(lp); fullScreenOverlay.setVisibility(View.VISIBLE); }
From source file:com.commonsware.cwac.crossport.design.widget.TextInputLayout.java
private void setEditText(EditText editText) { // If we already have an EditText, throw an exception if (mEditText != null) { throw new IllegalArgumentException("We already have an EditText, can only have one"); }/*from w ww.j av a2 s .co m*/ if (!(editText instanceof TextInputEditText)) { Log.i(LOG_TAG, "EditText added is not a TextInputEditText. Please switch to using that" + " class instead."); } mEditText = editText; final boolean hasPasswordTransformation = hasPasswordTransformation(); // Use the EditText's typeface, and it's text size for our expanded text if (!hasPasswordTransformation) { // We don't want a monospace font just because we have a password field mCollapsingTextHelper.setTypefaces(mEditText.getTypeface()); } mCollapsingTextHelper.setExpandedTextSize(mEditText.getTextSize()); final int editTextGravity = mEditText.getGravity(); mCollapsingTextHelper .setCollapsedTextGravity(Gravity.TOP | (editTextGravity & ~Gravity.VERTICAL_GRAVITY_MASK)); mCollapsingTextHelper.setExpandedTextGravity(editTextGravity); // Add a TextWatcher so that we know when the text input has changed mEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { updateLabelState(!mRestoringSavedState); if (mCounterEnabled) { updateCounter(s.length()); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // Use the EditText's hint colors if we don't have one set if (mDefaultTextColor == null) { mDefaultTextColor = mEditText.getHintTextColors(); } // If we do not have a valid hint, try and retrieve it from the EditText, if enabled if (mHintEnabled && TextUtils.isEmpty(mHint)) { // Save the hint so it can be restored on dispatchProvideAutofillStructure(); mOriginalHint = mEditText.getHint(); setHint(mOriginalHint); // Clear the EditText's hint as we will display it ourselves mEditText.setHint(null); } if (mCounterView != null) { updateCounter(mEditText.getText().length()); } if (mIndicatorArea != null) { adjustIndicatorPadding(); } updatePasswordToggleView(); // Update the label visibility with no animation, but force a state change updateLabelState(false, true); }
From source file:com.scoreflex.ScoreflexView.java
public void startOpeningAnimation() { int gravity = getLayoutGravity(); int anim = (Gravity.TOP == (gravity & Gravity.VERTICAL_GRAVITY_MASK)) ? R.anim.scoreflex_enter_slide_down : R.anim.scoreflex_enter_slide_up; Animation animation = AnimationUtils.loadAnimation(mParentActivity, anim); this.startAnimation(animation); }
From source file:android.support.wear.widget.drawer.WearableDrawerLayout.java
/** * Open the specified drawer by animating it into view. * * @param gravity Gravity.TOP to move the top drawer or Gravity.BOTTOM for the bottom. *///from www. ja v a2 s. com void openDrawer(int gravity) { if (!isLaidOut()) { switch (gravity) { case Gravity.TOP: mShouldOpenTopDrawerAfterLayout = true; break; case Gravity.BOTTOM: mShouldOpenBottomDrawerAfterLayout = true; break; default: // fall out } return; } openDrawer(findDrawerWithGravity(gravity)); }
From source file:com.facebook.react.views.textinput.ReactTextInputManager.java
@ReactProp(name = ViewProps.TEXT_ALIGN_VERTICAL) public void setTextAlignVertical(ReactEditText view, @Nullable String textAlignVertical) { if (textAlignVertical == null || "auto".equals(textAlignVertical)) { view.setGravityVertical(Gravity.NO_GRAVITY); } else if ("top".equals(textAlignVertical)) { view.setGravityVertical(Gravity.TOP); } else if ("bottom".equals(textAlignVertical)) { view.setGravityVertical(Gravity.BOTTOM); } else if ("center".equals(textAlignVertical)) { view.setGravityVertical(Gravity.CENTER_VERTICAL); } else {/* w w w .ja v a 2s . com*/ throw new JSApplicationIllegalArgumentException("Invalid textAlignVertical: " + textAlignVertical); } }
From source file:com.androidhuman.circlerefreshlayout.SwipeRefreshLayout.java
/** * Notify the widget that refresh state has changed. Do not call this when * refresh is triggered by a swipe gesture. * * @param refreshing Whether or not the view should show refresh progress. *///from w ww . j a va 2s . c om public void setRefreshing(boolean refreshing) { if ((refreshing && mRefreshing) != refreshing) { // scale and show mRefreshing = true; int endTarget; if (!mUsingCustomStart) { if (Gravity.TOP == mPullPosition) { endTarget = (int) (mSpinnerFinalOffset + mOriginalOffsetEdge); } else { endTarget = (int) (getMeasuredHeight() - mSpinnerFinalOffset); } } else { endTarget = (int) mSpinnerFinalOffset; } setTargetOffsetTopAndBottom(endTarget - mCurrentTargetOffsetTop, true /* requires update */); mNotify = false; startScaleUpAnimation(mRefreshListener); } else { setRefreshing(refreshing, false /* notify */); } }
From source file:co.carlosjimenez.android.currencyalerts.app.MainActivityFragment.java
/** * Method to set the position of the FAB button according to the material design guidelines. *///w ww .j av a 2s . c o m private void addFloatingActionButton() { final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab); final int spacingDouble = getResources().getDimensionPixelSize(R.dimen.spacing_double); int bottomOfToolbar = mAppBarLayout.getBottom(); final CoordinatorLayout.LayoutParams fabLayoutParams = new CoordinatorLayout.LayoutParams(fabSize, fabSize); fabLayoutParams.gravity = Gravity.END | Gravity.TOP; final int halfAFab = fabSize / 2; fabLayoutParams.setMargins(0, // left bottomOfToolbar - halfAFab, //top 0, // right spacingDouble); // bottom MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, spacingDouble); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Account for the fab's emulated shadow. fabLayoutParams.topMargin -= (mCalculateButton.getPaddingTop() / 2); } mCoordinatorLayout.addView(mCalculateButton, fabLayoutParams); }
From source file:cm.aptoide.pt.webservices.login.Login.java
private void checkCredentials(String username, String password) { if (username.trim().length() > 0 && password.trim().length() > 0) { new CheckUserCredentials().execute(username, password, "false"); } else {/*w w w .j ava 2 s . c o m*/ Toast toast = Toast.makeText(context, context.getString(R.string.check_your_credentials), Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 30); toast.show(); } }
From source file:com.itsronald.widget.ViewPagerIndicator.java
/** * Calculate the starting vertical position for the line of indicator dots. * @return The first Y coordinate where the indicator dots start. *///from w w w .j a va 2 s . c o m @Px private int calculateIndicatorDotTop() { final int top; final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (verticalGravity) { default: case Gravity.CENTER_VERTICAL: top = (getHeight() - getPaddingTop() - getPaddingBottom()) / 2 - getDotRadius(); break; case Gravity.TOP: top = getPaddingTop(); break; case Gravity.BOTTOM: top = getHeight() - getPaddingBottom() - 2 * getDotRadius(); break; } return top; }
From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java
/** * Check the lock mode of the drawer with the given gravity. * * @param edgeGravity Gravity of the drawer to check * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. *///from w ww . j av a 2 s . co m public int getDrawerLockMode(int edgeGravity) { final int absGrav = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGrav == Gravity.TOP) { return mLockModeTop; } else if (absGrav == Gravity.BOTTOM) { return mLockModeBottom; } return LOCK_MODE_UNLOCKED; }