List of usage examples for android.view Gravity BOTTOM
int BOTTOM
To view the source code for android.view Gravity BOTTOM.
Click Source Link
From source file:com.tmall.ultraviewpager.sample.PagerActivity.java
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (ultraViewPager.getIndicator() == null) { ultraViewPager.initIndicator();/*from www.j a v a2 s . c o m*/ ultraViewPager.getIndicator().setOrientation(gravity_indicator); } if (parent == indicatorStyle) { switch (position) { case 0: ultraViewPager.disableIndicator(); break; case 1: ultraViewPager.getIndicator().setFocusResId(0).setNormalResId(0); ultraViewPager.getIndicator().setFocusColor(Color.GREEN).setNormalColor(Color.WHITE) .setRadius((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics())); break; case 2: ultraViewPager.getIndicator().setFocusResId(R.mipmap.tm_biz_lifemaster_indicator_selected) .setNormalResId(R.mipmap.tm_biz_lifemaster_indicator_normal); break; case 3: break; } } if (parent == indicatorGravityHor) { switch (position) { case 0: gravity_hor = Gravity.LEFT; break; case 1: gravity_hor = Gravity.RIGHT; break; case 2: gravity_hor = Gravity.CENTER_HORIZONTAL; break; } if (ultraViewPager.getIndicator() != null) { if (gravity_ver != 0) { ultraViewPager.getIndicator().setGravity(gravity_hor | gravity_ver); } else { ultraViewPager.getIndicator().setGravity(gravity_hor); } } } if (parent == indicatorGravityVer) { switch (position) { case 0: gravity_ver = Gravity.TOP; break; case 1: gravity_ver = Gravity.BOTTOM; break; case 2: gravity_ver = Gravity.CENTER_VERTICAL; break; } if (ultraViewPager.getIndicator() != null) { if (gravity_hor != 0) { ultraViewPager.getIndicator().setGravity(gravity_hor | gravity_ver); } else { ultraViewPager.getIndicator().setGravity(gravity_ver); } } } }
From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java
public VerticalDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final float density = getResources().getDisplayMetrics().density; mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f); final float minVel = MIN_FLING_VELOCITY * density; mTopCallback = new ViewDragCallback(Gravity.TOP); mBottomCallback = new ViewDragCallback(Gravity.BOTTOM); mTopDragger = ViewDragHelper.create(this, 0.5f, mTopCallback); mTopDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP); mTopDragger.setMinVelocity(minVel);// w ww . j ava2 s. c om mTopCallback.setDragger(mTopDragger); mBottomDragger = ViewDragHelper.create(this, 0.5f, mBottomCallback); mBottomDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM); mBottomDragger.setMinVelocity(minVel); mBottomCallback.setDragger(mBottomDragger); // So that we can catch the back button setFocusableInTouchMode(true); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewGroupCompat.setMotionEventSplittingEnabled(this, false); }
From source file:cn.com.caronwer.activity.AuthSecondActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.bt_ok: getImg();/*from w ww . j a v a 2s .c o m*/ if (isCardNoImgSuccess && isDrivingLicenseImgSuccess && isCarHeadImgSuccess && isCarTailImgSuccess && isCarLeftImgSuccess && isCarRightImgSuccess) { uploadImg(); } else { showShortToastByString("??"); } break; case R.id.iv_left_white: finish(); break; case R.id.upload_card_no: case R.id.card_no_img: imgType = 0; menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.upload_driving_license: case R.id.driving_license_img: imgType = 1; menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.upload_car_head: case R.id.car_head_img: imgType = 2; menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.upload_car_tail: case R.id.car_tail_img: imgType = 3; menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.upload_car_left: case R.id.car_left_img: imgType = 4; menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; case R.id.upload_car_right: case R.id.car_right_img: imgType = 5; menuWindow = new SelectPicPopupWindow(AuthSecondActivity.this, itemsOnClick); menuWindow.showAtLocation(findViewById(R.id.auth_second), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); break; } }
From source file:com.actionbarsherlock.internal.view.menu.ActionMenuItemView.java
@Override public boolean onLongClick(View v) { if (hasText()) { // Don't show the cheat sheet for items that already show text. return false; }/*from w w w . j a v a2 s .co m*/ final int[] screenPos = new int[2]; final Rect displayFrame = new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context = getContext(); final int width = getWidth(); final int height = getHeight(); final int midy = screenPos[1] + height / 2; final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { // Show along the top; follow action buttons cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, screenWidth - screenPos[0] - width / 2, height); } else { // Show along the bottom center cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); } cheatSheet.show(); return true; }
From source file:com.akshay.protocol10.asplayer.widget.SlidingUpPanelLayout.java
public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) { mShadowDrawable = null;/*from ww w . j a v a2 s. c o m*/ mDragHelper = null; return; } if (attrs != null) { TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS); if (defAttrs != null) { int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY); if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) { throw new IllegalArgumentException("gravity must be set to either top or bottom"); } mIsSlidingUp = gravity == Gravity.BOTTOM; } defAttrs.recycle(); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout); if (ta != null) { mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_panelHeight, -1); mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_shadowHeight, -1); mParallaxOffset = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_paralaxOffset, -1); mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_flingVelocity, DEFAULT_MIN_FLING_VELOCITY); mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_fadeColor, DEFAULT_FADE_COLOR); mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1); mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_overlay, DEFAULT_OVERLAY_FLAG); mAnchorPoint = ta.getFloat(R.styleable.SlidingUpPanelLayout_anchorPoint, DEFAULT_ANCHOR_POINT); mSlideState = SlideState.values()[ta.getInt(R.styleable.SlidingUpPanelLayout_initialState, DEFAULT_SLIDE_STATE.ordinal())]; } ta.recycle(); } final float density = context.getResources().getDisplayMetrics().density; if (mPanelHeight == -1) { mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f); } if (mShadowHeight == -1) { mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f); } if (mParallaxOffset == -1) { mParallaxOffset = (int) (DEFAULT_PARALAX_OFFSET * density); } // If the shadow height is zero, don't show the shadow if (mShadowHeight > 0) { if (mIsSlidingUp) { mShadowDrawable = getResources().getDrawable(R.drawable.above_shadow); } else { mShadowDrawable = getResources().getDrawable(R.drawable.below_shadow); } } else { mShadowDrawable = null; } setWillNotDraw(false); mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback()); mDragHelper.setMinVelocity(mMinFlingVelocity * density); mIsSlidingEnabled = true; }
From source file:com.ideascontest.navi.uask.MainQuestionAnswerAdapter.java
/** * OnBindViewHolder is called by the RecyclerView to display the data at the specified * position. In this method, we update the contents of the ViewHolder to display the correct * indices in the list for this particular position, using the "position" argument that is conveniently * passed into us./* www .j a v a 2 s . c o m*/ * * @param holder The ViewHolder which should be updated to represent the contents of the * item at the given position in the data set. * @param position The position of the item within the adapter's data set. */ @Override public void onBindViewHolder(QuestionTopAnswerHolder holder, int position) { Log.d(TAG, "#" + position); QuestionTopAnswerHolder questionTopAnswerHolder = (QuestionTopAnswerHolder) holder; final Context context = questionTopAnswerHolder.v.getContext(); Log.d(TAG, "Category" + _category); switch (_category) { case 0: case 1: case 2: case 3: case 4: { if (position == 0) { /* String infoText = (String) questionTopAnswerHolder.basicInfoText.getText(); int count = infoText.split("\n").length; int upperLimit = (count > 5) ? MainAnswerAdapter.ordinalIndexOf(infoText, "\n", 5) : 140; if (infoText.length() > 140 || count > 5) { infoText = infoText.substring(0, upperLimit) + "... " + "view more"; SpannableString sText = new SpannableString(infoText); ClickableSpan myClickableSpan = new ClickableSpan() { @Override public void onClick(View v) { Log.d("MainCanvas Category", "clickable Span"); //finish(); } }; int spanLowLimit = upperLimit + 4; int spanHighLimit = upperLimit + 13; sText.setSpan(myClickableSpan, spanLowLimit, spanHighLimit, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sText.setSpan(new RelativeSizeSpan(0.75f), spanLowLimit, spanHighLimit, 0); sText.setSpan(new ForegroundColorSpan( questionTopAnswerHolder.v.getResources().getColor(R.color.primaryOrange)), spanLowLimit, spanHighLimit, 0); questionTopAnswerHolder.basicInfoText.setText(sText); questionTopAnswerHolder.basicInfoText.setMovementMethod(LinkMovementMethod.getInstance()); }*/ String infoText = (String) questionTopAnswerHolder.basicInfoText.getText(); int upperLimit = 150; if (infoText.length() > 150) { infoText = infoText.substring(0, upperLimit) + "... " + "view more"; SpannableString sText = new SpannableString(infoText); ClickableSpan myClickableSpan = new ClickableSpan() { @Override public void onClick(View v) { Log.d("Mainadapter Category", "clickable Span"); Intent intent = new Intent(context, ShowBasicInfo.class); intent.putExtra("category", _category); context.startActivity(intent);//finish(); } }; int spanLowLimit = upperLimit + 4; int spanHighLimit = upperLimit + 13; sText.setSpan(myClickableSpan, spanLowLimit, spanHighLimit, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sText.setSpan(new RelativeSizeSpan(0.75f), spanLowLimit, spanHighLimit, 0); sText.setSpan( new ForegroundColorSpan( questionTopAnswerHolder.v.getResources().getColor(R.color.primaryOrange)), spanLowLimit, spanHighLimit, 0); questionTopAnswerHolder.basicInfoText.setText(sText); questionTopAnswerHolder.basicInfoText.setMovementMethod(LinkMovementMethod.getInstance()); } } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; case 5: { if (position == 0) { questionTopAnswerHolder.basicInfoText.setText("List of all non-categorical questions"); questionTopAnswerHolder.basicInfoText.setGravity(Gravity.CENTER | Gravity.BOTTOM); questionTopAnswerHolder.headingText.setVisibility(View.INVISIBLE); } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; case 6: { if (position == 0) { questionTopAnswerHolder.basicInfoText.setText("List of all questions asked by you."); questionTopAnswerHolder.basicInfoText.setGravity(Gravity.CENTER | Gravity.BOTTOM); questionTopAnswerHolder.headingText.setVisibility(View.INVISIBLE); } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; case 7: { if (position == 0) { questionTopAnswerHolder.basicInfoText.setText("List of all questions answered by you."); questionTopAnswerHolder.basicInfoText.setGravity(Gravity.CENTER | Gravity.BOTTOM); questionTopAnswerHolder.headingText.setVisibility(View.INVISIBLE); } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; case 8: { if (position == 0) { questionTopAnswerHolder.basicInfoText.setText( "All the private questions asked by your faculty students. Visible only to fellow faculty students"); questionTopAnswerHolder.basicInfoText.setGravity(Gravity.CENTER | Gravity.BOTTOM); questionTopAnswerHolder.headingText.setVisibility(View.INVISIBLE); } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; default: { populateDynamicUiElements(questionTopAnswerHolder, position); } break; } }
From source file:com.google.android.apps.muzei.ArtDetailFragment.java
@Override public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) { mStatusBarScrimView = view.findViewById(R.id.statusbar_scrim); mChromeContainerView.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0xaa000000, 8, Gravity.BOTTOM)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mStatusBarScrimView.setVisibility(View.GONE); mStatusBarScrimView = null;/*from www.j a v a 2s. c o m*/ } else { mStatusBarScrimView.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0x44000000, 8, Gravity.TOP)); } mMetadataView = view.findViewById(R.id.metadata); final float metadataSlideDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); mContainerView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { final boolean visible = (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) == 0; mChromeContainerView.setVisibility(View.VISIBLE); mChromeContainerView.animate().alpha(visible ? 1f : 0f) .translationY(visible ? 0 : metadataSlideDistance).setDuration(200) .withEndAction(new Runnable() { @Override public void run() { if (!visible) { mChromeContainerView.setVisibility(View.GONE); } } }); if (mStatusBarScrimView != null) { mStatusBarScrimView.setVisibility(View.VISIBLE); mStatusBarScrimView.animate().alpha(visible ? 1f : 0f).setDuration(200) .withEndAction(new Runnable() { @Override public void run() { if (!visible) { mStatusBarScrimView.setVisibility(View.GONE); } } }); } } }); mTitleView = (TextView) view.findViewById(R.id.title); mBylineView = (TextView) view.findViewById(R.id.byline); mAttributionView = (TextView) view.findViewById(R.id.attribution); final View overflowButton = view.findViewById(R.id.overflow_button); mOverflowMenu = new PopupMenu(getContext(), overflowButton); overflowButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); overflowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mOverflowMenu.show(); } }); mOverflowMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { int id = mOverflowSourceActionMap.get(menuItem.getItemId()); if (id > 0) { SourceManager.sendAction(getContext(), id); return true; } switch (menuItem.getItemId()) { case R.id.action_settings: FirebaseAnalytics.getInstance(getContext()).logEvent("settings_open", null); startActivity(new Intent(getContext(), SettingsActivity.class)); return true; } return false; } }); mNextButton = view.findViewById(R.id.next_button); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { SourceManager.sendAction(getContext(), MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK); mNextFakeLoading = true; showNextFakeLoading(); } }); CheatSheet.setup(mNextButton); mPanScaleProxyView = (PanScaleProxyView) view.findViewById(R.id.pan_scale_proxy); mPanScaleProxyView.setMaxZoom(5); mPanScaleProxyView.setOnViewportChangedListener(new PanScaleProxyView.OnViewportChangedListener() { @Override public void onViewportChanged() { if (mGuardViewportChangeListener) { return; } ArtDetailViewport.getInstance().setViewport(mCurrentViewportId, mPanScaleProxyView.getCurrentViewport(), true); } }); mPanScaleProxyView.setOnOtherGestureListener(new PanScaleProxyView.OnOtherGestureListener() { @Override public void onSingleTapUp() { showHideChrome((mContainerView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0); } }); mLoadingContainerView = view.findViewById(R.id.image_loading_container); mLoadingIndicatorView = (AnimatedMuzeiLoadingSpinnerView) view.findViewById(R.id.image_loading_indicator); mLoadErrorContainerView = view.findViewById(R.id.image_error_container); mLoadErrorEasterEggView = view.findViewById(R.id.error_easter_egg); view.findViewById(R.id.image_error_retry_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showNextFakeLoading(); getContext().startService(TaskQueueService.getDownloadCurrentArtworkIntent(getContext())); } }); }
From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java
public VerticalDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final float density = getResources().getDisplayMetrics().density; mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f); final float minVel = MIN_FLING_VELOCITY * density; mTopCallback = new ViewDragCallback(Gravity.TOP); mBottomCallback = new ViewDragCallback(Gravity.BOTTOM); mTopDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mTopCallback); mTopDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP); mTopDragger.setMinVelocity(minVel);//from w ww. java2s. c om mTopCallback.setDragger(mTopDragger); mBottomDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mBottomCallback); mBottomDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM); mBottomDragger.setMinVelocity(minVel); mBottomCallback.setDragger(mBottomDragger); // So that we can catch the back button setFocusableInTouchMode(true); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewGroupCompat.setMotionEventSplittingEnabled(this, false); }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityJourney.java
/** * sends a message to the driver of a journey *///from www. j a va 2s . com private void sendMessageToDriver() { final Dialog customDialog = new Dialog(this); customDialog.setContentView(R.layout.custom_dialog_layout); customDialog.setTitle("Message"); final List<String> spinnerArray = new ArrayList<String>(); spinnerArray.add("Everyone"); if (!getApp().getSelectedJourney().getDriver().equals(getApp().getUser())) { spinnerArray.add(getApp().getSelectedJourney().getDriver().getFullName()); } for (int i = 0; i < getApp().getSelectedJourney().getHitchhikers().size(); i++) { if (!getApp().getSelectedJourney().getHitchhikers().get(i).equals(getApp().getUser())) { spinnerArray.add(getApp().getSelectedJourney().getHitchhikers().get(i).getFullName()); } } final Spinner spinner = (Spinner) customDialog.findViewById(R.id.spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(MapActivityJourney.this, android.R.layout.simple_spinner_item, spinnerArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); ImageView sendBtn = (ImageView) customDialog.findViewById(R.id.sendBtn); final EditText input = (EditText) customDialog.findViewById(R.id.input); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { User mid = getApp().getUser(); if (spinner.getSelectedItem().toString().equals("Everyone")) { if (input.getText().toString().equals("")) { input.setHint("Please fill in your message"); Toast toast = Toast.makeText(MapActivityJourney.this, "Please fill in your message", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); } else { List<User> userList = new ArrayList<User>(); userList.add(getApp().getSelectedJourney().getDriver()); for (int k = 0; k < getApp().getSelectedJourney().getHitchhikers().size(); k++) { userList.add(getApp().getSelectedJourney().getHitchhikers().get(k)); } userList.remove(getApp().getUser()); for (int k = 0; k < userList.size(); k++) { sendMessage(userList.get(k), input); } Toast toast = Toast.makeText(MapActivityJourney.this, "Message sent", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); customDialog.dismiss(); } } else { for (int j = 0; j < getApp().getSelectedJourney().getHitchhikers().size(); j++) { if (spinner.getSelectedItem().toString() .equals(getApp().getSelectedJourney().getHitchhikers().get(j).getFullName())) { mid = getApp().getSelectedJourney().getHitchhikers().get(j); } } if (spinner.getSelectedItem().toString() .equals(getApp().getSelectedJourney().getDriver().getFullName())) { mid = getApp().getSelectedJourney().getDriver(); } if (input.getText().toString().equals("")) { input.setHint("Please fill in your message"); Toast toast = Toast.makeText(MapActivityJourney.this, "Please fill in your message", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); } else { sendMessage(mid, input); Toast toast = Toast.makeText(MapActivityJourney.this, "Message sent", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); customDialog.dismiss(); } } } }); customDialog.show(); }
From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java
private void configContentView() { if (mContentView instanceof TextView) { TextView tv = (TextView) mContentView; tv.setText(mText);/*from w w w .j av a2 s.c o m*/ } else { TextView tv = (TextView) mContentView.findViewById(mTextViewId); if (tv != null) tv.setText(mText); } mContentView.setPadding((int) mPadding, (int) mPadding, (int) mPadding, (int) mPadding); if (mShowArrow) { mArrowView = new ImageView(mContext); mArrowView.setImageDrawable(mArrowDrawable); LinearLayoutCompat.LayoutParams arrowLayoutParams; if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) { arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowWidth, (int) mArrowHeight, 0); } else { arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowHeight, (int) mArrowWidth, 0); } mArrowView.setLayoutParams(arrowLayoutParams); LinearLayoutCompat linearLayout = new LinearLayoutCompat(mContext); linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setOrientation( mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayoutCompat.HORIZONTAL : LinearLayoutCompat.VERTICAL); int padding = mAnimated ? mAnimationPadding : (int) SimpleTooltipUtils.pxFromDp(4); linearLayout.setPadding(padding, padding, padding, padding); if (mGravity == Gravity.TOP || mGravity == Gravity.START) { linearLayout.addView(mContentView); linearLayout.addView(mArrowView); } else { linearLayout.addView(mArrowView); linearLayout.addView(mContentView); } LinearLayoutCompat.LayoutParams contentViewParams = new LinearLayoutCompat.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); contentViewParams.gravity = Gravity.CENTER; mContentView.setLayoutParams(contentViewParams); mContentLayout = linearLayout; } else { mContentLayout = mContentView; mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } mContentLayout.setVisibility(View.INVISIBLE); mPopupWindow.setContentView(mContentLayout); }