List of usage examples for android.view Gravity START
int START
To view the source code for android.view Gravity START.
Click Source Link
From source file:com.lite.android.launcher3.allapps.AllAppsGridAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { boolean hideIconLabels = SettingsProvider.getBoolean(mLauncher, SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS, R.bool.preferences_interface_drawer_hide_icon_labels_default); FastScrollFocusApplicator.setFastScrollDimmed(holder.mContent, false, false); FastScrollFocusApplicator.setFastScrollFocused(holder.mContent, false, false); switch (holder.getItemViewType()) { case ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.setTextColor(mAllAppsTextColor); if (hideIconLabels) { icon.setTextVisibility(!hideIconLabels); }/* w ww. j a va 2s .c om*/ icon.applyFromApplicationInfo(info); FastScrollFocusApplicator.setFastScrollDimmed(icon, shouldDimPosition(position), !mIconsDimmed); FastScrollFocusApplicator.setFastScrollFocused(icon, false, !mIconsDimmed); break; } case PREDICTION_ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.setTextColor(mAllAppsTextColor); if (hideIconLabels) { icon.setTextVisibility(!hideIconLabels); } icon.applyFromApplicationInfo(info); FastScrollFocusApplicator.setFastScrollDimmed(icon, shouldDimPosition(position), !mIconsDimmed); FastScrollFocusApplicator.setFastScrollFocused(icon, false, !mIconsDimmed); mRemoteFolderManager.onBindViewHolder(holder, info); break; } case EMPTY_SEARCH_VIEW_TYPE: TextView emptyViewText = (TextView) holder.mContent; emptyViewText.setText(mEmptySearchMessage); emptyViewText.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); break; case SEARCH_MARKET_VIEW_TYPE: TextView searchView = (TextView) holder.mContent; if (mMarketSearchIntent != null) { searchView.setVisibility(View.VISIBLE); searchView.setContentDescription(mMarketSearchMessage); searchView.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); searchView.setText(mMarketSearchMessage); } else { searchView.setVisibility(View.GONE); } break; case CUSTOM_PREDICTED_APPS_HEADER_VIEW_TYPE: { TextView title = (TextView) holder.mContent.findViewById(R.id.title); title.setTextColor(mAllAppsTextColor); FastScrollFocusApplicator.setFastScrollDimmed(holder.mContent, shouldDimPosition(position), !mIconsDimmed); FastScrollFocusApplicator.setFastScrollFocused(holder.mContent, false, !mIconsDimmed); ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) holder.mContent.getLayoutParams(); mCustomPredictedAppsHeaderHeight = holder.mContent.getHeight() + lp.topMargin + lp.bottomMargin; break; } case CUSTOM_PREDICTED_APPS_FOOTER_VIEW_TYPE: ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) holder.mContent.getLayoutParams(); mCustomPredictedAppsFooterHeight = holder.mContent.getHeight() + lp.topMargin + lp.bottomMargin; } }
From source file:com.keylesspalace.tusky.activity.ComposeActivity.java
private EditText createEditText(String[] contentMimeTypes) { final String[] mimeTypes; if (contentMimeTypes == null || contentMimeTypes.length == 0) { mimeTypes = new String[0]; } else {//from w ww . j a va 2 s . c o m mimeTypes = Arrays.copyOf(contentMimeTypes, contentMimeTypes.length); } EditText editText = new android.support.v7.widget.AppCompatEditText(this) { @Override public InputConnection onCreateInputConnection(EditorInfo editorInfo) { final InputConnection ic = super.onCreateInputConnection(editorInfo); EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes); final InputConnectionCompat.OnCommitContentListener callback = new InputConnectionCompat.OnCommitContentListener() { @Override public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) { return ComposeActivity.this.onCommitContent(inputContentInfo, flags, mimeTypes); } }; return InputConnectionCompat.createWrapper(ic, editorInfo, callback); } }; ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); editText.setLayoutParams(layoutParams); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE); editText.setEms(10); editText.setBackgroundColor(0); editText.setGravity(Gravity.START | Gravity.TOP); editText.setHint(R.string.hint_compose); return editText; }
From source file:net.opacapp.multilinecollapsingtoolbar.CollapsingTextHelper.java
private void calculateUsingTextSize(final float textSize) { if (mText == null) return;//from w w w. jav a2 s .c om final float availableWidth; final float newTextSize; boolean updateDrawText = false; // BEGIN MODIFICATION: Add maxLines variable int maxLines; // END MODIFICATION if (isClose(textSize, mCollapsedTextSize)) { availableWidth = mCollapsedBounds.width(); newTextSize = mCollapsedTextSize; mScale = 1f; if (mCurrentTypeface != mCollapsedTypeface) { mCurrentTypeface = mCollapsedTypeface; updateDrawText = true; } // BEGIN MODIFICATION: Set maxLines variable maxLines = 1; // END MODIFICATION } else { availableWidth = mExpandedBounds.width(); newTextSize = mExpandedTextSize; if (mCurrentTypeface != mExpandedTypeface) { mCurrentTypeface = mExpandedTypeface; updateDrawText = true; } if (isClose(textSize, mExpandedTextSize)) { // If we're close to the expanded text size, snap to it and use a scale of 1 mScale = 1f; } else { // Else, we'll scale down from the expanded text size mScale = textSize / mExpandedTextSize; } // BEGIN MODIFICATION: Set maxLines variable maxLines = this.maxLines; // END MODIFICATION } if (availableWidth > 0) { updateDrawText = (mCurrentTextSize != newTextSize) || mBoundsChanged || updateDrawText; mCurrentTextSize = newTextSize; mBoundsChanged = false; } if (mTextToDraw == null || updateDrawText) { mTextPaint.setTextSize(mCurrentTextSize); mTextPaint.setTypeface(mCurrentTypeface); // BEGIN MODIFICATION: Text layout creation and text truncation StaticLayout layout = new StaticLayout(mText, mTextPaint, (int) availableWidth, Layout.Alignment.ALIGN_NORMAL, 1, 0, false); CharSequence truncatedText; if (layout.getLineCount() > maxLines) { int lastLine = maxLines - 1; CharSequence textBefore = lastLine > 0 ? mText.subSequence(0, layout.getLineEnd(lastLine - 1)) : ""; CharSequence lineText = mText.subSequence(layout.getLineStart(lastLine), layout.getLineEnd(lastLine)); // if last char in line is space, move it behind the ellipsis CharSequence lineEnd = ""; if (lineText.charAt(lineText.length() - 1) == ' ') { lineEnd = lineText.subSequence(lineText.length() - 1, lineText.length()); lineText = lineText.subSequence(0, lineText.length() - 1); } // insert ellipsis character lineText = TextUtils.concat(lineText, "\u2026", lineEnd); // if the text is too long, truncate it CharSequence truncatedLineText = TextUtils.ellipsize(lineText, mTextPaint, availableWidth, TextUtils.TruncateAt.END); truncatedText = TextUtils.concat(textBefore, truncatedLineText); } else { truncatedText = mText; } if (!TextUtils.equals(truncatedText, mTextToDraw)) { mTextToDraw = truncatedText; mIsRtl = calculateIsRtl(mTextToDraw); } final Layout.Alignment alignment; // Don't rectify gravity for RTL languages, Layout.Alignment does it already. switch (mExpandedTextGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: alignment = Layout.Alignment.ALIGN_CENTER; break; case Gravity.RIGHT: case Gravity.END: alignment = Layout.Alignment.ALIGN_OPPOSITE; break; case Gravity.LEFT: case Gravity.START: default: alignment = Layout.Alignment.ALIGN_NORMAL; break; } mTextLayout = new StaticLayout(mTextToDraw, mTextPaint, (int) availableWidth, alignment, 1, 0, false); // END MODIFICATION } }
From source file:com.google.samples.apps.sergio.ui.BaseActivity.java
private void populateAccountList(List<Account> accounts) { mAccountListContainer.removeAllViews(); LayoutInflater layoutInflater = LayoutInflater.from(this); for (Account account : accounts) { View itemView = layoutInflater.inflate(R.layout.list_item_account, mAccountListContainer, false); ((TextView) itemView.findViewById(R.id.profile_email_text)).setText(account.name); final String accountName = account.name; String imageUrl = AccountUtils.getPlusImageUrl(this, accountName); if (!TextUtils.isEmpty(imageUrl)) { mImageLoader.loadImage(imageUrl, (ImageView) itemView.findViewById(R.id.profile_image)); }/*from ww w .j a v a 2 s. c o m*/ itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork == null || !activeNetwork.isConnected()) { // if there's no network, don't try to change the selected account Toast.makeText(BaseActivity.this, R.string.no_connection_cant_login, Toast.LENGTH_SHORT) .show(); mDrawerLayout.closeDrawer(Gravity.START); return; } else { LOGD(TAG, "User requested switch to account: " + accountName); AccountUtils.setActiveAccount(BaseActivity.this, accountName); onAccountChangeRequested(); startLoginProcess(); mAccountBoxExpanded = false; setupAccountBoxToggle(); mDrawerLayout.closeDrawer(Gravity.START); setupAccountBox(); } } }); mAccountListContainer.addView(itemView); } }
From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java
private Animator createAnimator(View view, boolean fadeIn, int slideDirection, long startDelay) { boolean isLtr = getView().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; boolean slideRight = (isLtr && slideDirection == Gravity.END) || (!isLtr && slideDirection == Gravity.START) || slideDirection == Gravity.RIGHT; Animator fadeAnimator;//from ww w . ja v a 2s . c o m Animator slideAnimator; if (fadeIn) { fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 0.0f, 1.0f); slideAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, slideRight ? sSlideDistance : -sSlideDistance, 0); fadeAnimator.setInterpolator(HEADER_APPEAR_INTERPOLATOR); slideAnimator.setInterpolator(HEADER_APPEAR_INTERPOLATOR); } else { fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 1.0f, 0.0f); slideAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, 0, slideRight ? sSlideDistance : -sSlideDistance); fadeAnimator.setInterpolator(HEADER_DISAPPEAR_INTERPOLATOR); slideAnimator.setInterpolator(HEADER_DISAPPEAR_INTERPOLATOR); } fadeAnimator.setDuration(HEADER_ANIMATION_DURATION_MS); fadeAnimator.setTarget(view); slideAnimator.setDuration(HEADER_ANIMATION_DURATION_MS); slideAnimator.setTarget(view); AnimatorSet animator = new AnimatorSet(); animator.playTogether(fadeAnimator, slideAnimator); if (startDelay > 0) { animator.setStartDelay(startDelay); } return animator; }
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
/** * Initiate the dragging process. Create a bitmap that is displayed as the dragging event * happens and is moved around across the screen. This function is called once for each time * that a dragging event is initiated.//from ww w . j a v a 2 s . c o m * * The logic to this method was borrowed from the TouchInterceptor.java class from the * music app. * * @param draggedChild The child view being dragged * @param x The x coordinate of this view where dragging began * @param y The y coordinate of this view where dragging began */ private void startDragging(final View draggedChild, final int x, final int y) { if (!isDragReorderingSupported()) { return; } mDragBitmap = createDraggedChildBitmap(draggedChild); if (mDragBitmap == null) { // It appears that creating bitmaps for large views fail. For now, don't allow // dragging in this scenario. When using the framework's drag and drop implementation, // drag shadow also fails with a OutofResourceException when trying to draw the drag // shadow onto a Surface. mReorderHelper.handleDragCancelled(draggedChild); return; } mTouchOffsetToChildLeft = x - draggedChild.getLeft(); mTouchOffsetToChildTop = y - draggedChild.getTop(); updateReorderStates(ReorderUtils.DRAG_STATE_DRAGGING); initializeDragScrollParameters(y); final LayoutParams params = (LayoutParams) draggedChild.getLayoutParams(); mReorderHelper.handleDragStart(draggedChild, params.position, params.id, new Point(mTouchDownForDragStartX, mTouchDownForDragStartY)); // TODO: Reconsider using the framework's DragShadow support for dragging, // and only draw the bitmap in onDrop for animation. final Context context = getContext(); mDragView = new ImageView(context); mDragView.setImageBitmap(mDragBitmap); mDragView.setAlpha(160); mWindowParams = new WindowManager.LayoutParams(); mWindowParams.gravity = Gravity.TOP | Gravity.START; mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.flags = mWindowManagerLayoutFlags; mWindowParams.format = PixelFormat.TRANSLUCENT; // Use WindowManager to overlay a transparent image on drag mWindowManager.addView(mDragView, mWindowParams); updateDraggedBitmapLocation(x, y); }
From source file:com.sbgapps.scoreit.ui.ScoreItActivity.java
@Override public void onBackPressed() { invalidateOptionsMenu();/*from w ww. ja v a 2 s . com*/ if (mDrawerLayout.isDrawerOpen(mNavigationDrawer)) { mDrawerLayout.closeDrawer(Gravity.START); } else if (null != mLap) { mLap = null; mEditedLap = null; mIsEdited = false; animateLapContainer(); setActionButtonProperties(true); } else if (!isTablet() && null != mScoreGraphFragment) { switchScoreViews(); } else { super.onBackPressed(); } }
From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java
@Override public void onBackPressed() { if (!wideMode && drawerLayout.isDrawerOpen(Gravity.START)) { drawerLayout.closeDrawers();//from w w w . j av a2 s . c o m } else if (page != null) { if (setSearchMode(false)) { return; } PageHolder previousPageHolder = pageManager.getTargetPreviousPage(true); if (previousPageHolder != null) { pageManager.removeCurrentPageFromStack(); navigatePageHolder(previousPageHolder, true); } else { if (System.currentTimeMillis() - backPressed > 2000) { ClickableToast.show(this, R.string.message_press_again_to_exit); backPressed = System.currentTimeMillis(); } else { super.onBackPressed(); } } } }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) { final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance() .getCurrent().mShouldShowUiToAcceptTypedWord; final int stripWidth = addToDictionaryStrip.getWidth(); final int width = shouldShowUiToAcceptTypedWord ? stripWidth : stripWidth - mDividerWidth - mPadding * 2; final TextView wordView = (TextView) addToDictionaryStrip.findViewById(R.id.word_to_save); wordView.setTextColor(mColorTypedWord); final int wordWidth = (int) (width * mCenterSuggestionWeight); final CharSequence wordToSave = getEllipsizedText(word, wordWidth, wordView.getPaint()); final float wordScaleX = wordView.getTextScaleX(); wordView.setText(wordToSave);//from www.j ava2 s . c o m wordView.setTextScaleX(wordScaleX); setLayoutWeight(wordView, mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT); final int wordVisibility = shouldShowUiToAcceptTypedWord ? View.GONE : View.VISIBLE; wordView.setVisibility(wordVisibility); addToDictionaryStrip.findViewById(R.id.word_to_save_divider).setVisibility(wordVisibility); final Resources res = addToDictionaryStrip.getResources(); final CharSequence hintText; final int hintWidth; final float hintWeight; final TextView hintView = (TextView) addToDictionaryStrip.findViewById(R.id.hint_add_to_dictionary); if (shouldShowUiToAcceptTypedWord) { hintText = res.getText(R.string.hint_add_to_dictionary_without_word); hintWidth = width; hintWeight = 1.0f; hintView.setGravity(Gravity.CENTER); } else { final boolean isRtlLanguage = (ViewCompat .getLayoutDirection(addToDictionaryStrip) == ViewCompat.LAYOUT_DIRECTION_RTL); final String arrow = isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW; final boolean isRtlSystem = SubtypeLocaleUtils.isRtlLanguage(res.getConfiguration().locale); final CharSequence hint = res.getText(R.string.hint_add_to_dictionary); hintText = (isRtlLanguage == isRtlSystem) ? (arrow + hint) : (hint + arrow); hintWidth = width - wordWidth; hintWeight = 1.0f - mCenterSuggestionWeight; hintView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START); } hintView.setTextColor(mColorAutoCorrect); final float hintScaleX = getTextScaleX(hintText, hintWidth, hintView.getPaint()); hintView.setText(hintText); hintView.setTextScaleX(hintScaleX); setLayoutWeight(hintView, hintWeight, ViewGroup.LayoutParams.MATCH_PARENT); }
From source file:com.saarang.samples.apps.iosched.ui.BaseActivity.java
private void populateAccountList(List<Account> accounts) { mAccountListContainer.removeAllViews(); LayoutInflater layoutInflater = LayoutInflater.from(this); for (Account account : accounts) { View itemView = layoutInflater.inflate(com.saarang.samples.apps.iosched.R.layout.list_item_account, mAccountListContainer, false); ((TextView) itemView.findViewById(com.saarang.samples.apps.iosched.R.id.profile_email_text)) .setText(account.name);/*from w w w .java2s.c om*/ final String accountName = account.name; String imageUrl = AccountUtils.getPlusImageUrl(this, accountName); if (!TextUtils.isEmpty(imageUrl)) { mImageLoader.loadImage(imageUrl, (ImageView) itemView.findViewById(com.saarang.samples.apps.iosched.R.id.profile_image)); } itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork == null || !activeNetwork.isConnected()) { // if there's no network, don't try to change the selected account Toast.makeText(BaseActivity.this, com.saarang.samples.apps.iosched.R.string.no_connection_cant_login, Toast.LENGTH_SHORT).show(); mDrawerLayout.closeDrawer(Gravity.START); return; } else { LogUtils.LOGD(TAG, "User requested switch to account: " + accountName); AccountUtils.setActiveAccount(BaseActivity.this, accountName); onAccountChangeRequested(); startLoginProcess(); mAccountBoxExpanded = false; setupAccountBoxToggle(); mDrawerLayout.closeDrawer(Gravity.START); setupAccountBox(); } } }); mAccountListContainer.addView(itemView); } }