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.acious.android.paginationseekbar.internal.PopupIndicator.java
private WindowManager.LayoutParams createPopupLayout(IBinder token) { WindowManager.LayoutParams p = new WindowManager.LayoutParams(); p.gravity = Gravity.START | Gravity.TOP; p.width = ViewGroup.LayoutParams.MATCH_PARENT; p.height = ViewGroup.LayoutParams.MATCH_PARENT; p.format = PixelFormat.TRANSLUCENT;//from w ww.j a v a2s . co m p.flags = computeFlags(p.flags); p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; p.token = token; p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN; p.setTitle("PaginationSeekBar Indicator:" + Integer.toHexString(hashCode())); return p; }
From source file:kookmin.cs.sympathymusiz.VideoListDemoActivity.java
/** * Sets up the layout programatically for the three different states. Portrait, landscape or * fullscreen+landscape. This has to be done programmatically because we handle the orientation * changes ourselves in order to get fluent fullscreen transitions, so the xml layout resources * do not get reloaded.// w ww .j a v a 2 s . co m */ private void layout() { boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; //ArrayList<ArrayList<String>> list = (ArrayList<ArrayList<String>>) getIntent("exIntent""); listFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE); listFragment.setLabelVisibility(isPortrait); closeButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE); if (isFullscreen) { videoBox.setTranslationY(0); // Reset any translation that was applied in portrait. setLayoutSize(videoFragment.getView(), MATCH_PARENT, MATCH_PARENT); setLayoutSizeAndGravity(videoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT); } else if (isPortrait) { setLayoutSize(listFragment.getView(), MATCH_PARENT, MATCH_PARENT); setLayoutSize(videoFragment.getView(), MATCH_PARENT, WRAP_CONTENT); setLayoutSizeAndGravity(videoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM); } else { videoBox.setTranslationY(0); // Reset any translation that was applied in portrait. int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp); setLayoutSize(listFragment.getView(), screenWidth / 4, MATCH_PARENT); int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP); setLayoutSize(videoFragment.getView(), videoWidth, WRAP_CONTENT); setLayoutSizeAndGravity(videoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL); } }
From source file:com.hippo.nimingban.ui.PostActivity.java
private void showSwipeGuide() { new GuideHelper.Builder(this).setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary)) .setPadding(LayoutUtils.dp2pix(this, 16)).setMessagePosition(Gravity.TOP) .setMessage(getString(R.string.swipe_toolbar_hide_show)).setButton(getString(R.string.get_it)) .setBackgroundColor(0x73000000).setOnDissmisListener(new View.OnClickListener() { @Override/*from ww w . j a va 2 s . co m*/ public void onClick(View v) { Settings.putGuideTypeSend(false); } }).show(); }
From source file:de.bolz.android.taglocate.ui.TagEditActivity.java
/** * Shows a Toast on top of the view.//from w w w.j a v a2 s . c om * @param msg the message to display. * @param length the Toast duration */ protected void showToast(String msg, int length) { Toast t = Toast.makeText(this, msg, length); t.setGravity(Gravity.TOP, 0, 0); t.show(); }
From source file:com.birkettenterprise.phonelocator.activity.AuthenticationActivity.java
private void toast(int resourceId) { Toast toast = Toast.makeText(this, resourceId, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP, 0, 0); toast.show(); }
From source file:com.github.shareme.gwsdiscreteseekbar.library.Marker.java
@SuppressWarnings("SuspiciousNameCombination") @SuppressLint("SetTextI18n") public void resetSizes(String maxValue) { DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); //Account for negative numbers... is there any proper way of getting the biggest string between our range???? mNumber.setText("-" + maxValue); //Do a first forced measure call for the TextView (with the biggest text content), //to calculate the max width and use always the same. //this avoids the TextView from shrinking and growing when the text content changes int wSpec = MeasureSpec.makeMeasureSpec(displayMetrics.widthPixels, MeasureSpec.AT_MOST); int hSpec = MeasureSpec.makeMeasureSpec(displayMetrics.heightPixels, MeasureSpec.AT_MOST); mNumber.measure(wSpec, hSpec);// w ww . j a va 2s . c o m mWidth = Math.max(mNumber.getMeasuredWidth(), mNumber.getMeasuredHeight()); removeView(mNumber); addView(mNumber, new FrameLayout.LayoutParams(mWidth, mWidth, Gravity.LEFT | Gravity.TOP)); }
From source file:android.support.designox.widget.TextInputLayout.java
public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) { // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10 super(context, attrs); ThemeUtils.checkAppCompatTheme(context); setOrientation(VERTICAL);/*w ww . j ava2 s . co m*/ setWillNotDraw(false); setAddStatesFromChildren(true); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); mCollapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator()); mCollapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextInputLayout, defStyleAttr, R.style.Widget_Design_TextInputLayout); mHintEnabled = a.getBoolean(R.styleable.TextInputLayout_hintEnabled, true); setHint(a.getText(R.styleable.TextInputLayout_android_hint)); mHintAnimationEnabled = a.getBoolean(R.styleable.TextInputLayout_hintAnimationEnabled, true); if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) { mDefaultTextColor = mFocusedTextColor = a .getColorStateList(R.styleable.TextInputLayout_android_textColorHint); } final int hintAppearance = a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1); if (hintAppearance != -1) { setHintTextAppearance(a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0)); } mErrorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0); final boolean errorEnabled = a.getBoolean(R.styleable.TextInputLayout_errorEnabled, false); final boolean counterEnabled = a.getBoolean(R.styleable.TextInputLayout_counterEnabled, false); setCounterMaxLength(a.getInt(R.styleable.TextInputLayout_counterMaxLength, INVALID_MAX_LENGTH)); mCounterTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterTextAppearance, 0); mCounterOverflowTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterOverflowTextAppearance, 0); a.recycle(); setErrorEnabled(errorEnabled); setCounterEnabled(counterEnabled); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { // Make sure we're important for accessibility if we haven't been explicitly not ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate()); }
From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java
@SuppressLint("RtlHardcoded") @SuppressWarnings("deprecation") @Override/*from w w w. j av a 2s . c o m*/ protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.CONTEXT_MENU_APPEARING")); boolean isNonAppMenu = !getIntent().hasExtra("package_name") && !getIntent().hasExtra("app_name"); showStartMenu = getIntent().getBooleanExtra("launched_from_start_menu", false); isStartButton = isNonAppMenu && getIntent().getBooleanExtra("is_start_button", false); isOverflowMenu = isNonAppMenu && getIntent().getBooleanExtra("is_overflow_menu", false); contextMenuFix = getIntent().hasExtra("context_menu_fix"); // Determine where to position the dialog on screen WindowManager.LayoutParams params = getWindow().getAttributes(); DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); int statusBarHeight = 0; int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) statusBarHeight = getResources().getDimensionPixelSize(resourceId); if (showStartMenu) { int x = getIntent().getIntExtra("x", 0); int y = getIntent().getIntExtra("y", 0); int offset = getResources().getDimensionPixelSize( isOverflowMenu ? R.dimen.context_menu_offset_overflow : R.dimen.context_menu_offset); switch (U.getTaskbarPosition(this)) { case "bottom_left": case "bottom_vertical_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = x; params.y = display.getHeight() - y - offset; break; case "bottom_right": case "bottom_vertical_right": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset; params.y = display.getHeight() - y - offset; break; case "top_left": case "top_vertical_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = x; params.y = y - offset + statusBarHeight; break; case "top_right": case "top_vertical_right": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset; params.y = y - offset + statusBarHeight; break; } } else { LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); int x = getIntent().getIntExtra("x", display.getWidth()); int y = getIntent().getIntExtra("y", display.getHeight()); int offset = getResources().getDimensionPixelSize(R.dimen.icon_size); switch (U.getTaskbarPosition(this)) { case "bottom_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = isStartButton ? 0 : x; params.y = offset; break; case "bottom_vertical_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = offset; params.y = display.getHeight() - y - (isStartButton ? 0 : offset); break; case "bottom_right": params.gravity = Gravity.BOTTOM | Gravity.RIGHT; params.x = display.getWidth() - x; params.y = offset; break; case "bottom_vertical_right": params.gravity = Gravity.BOTTOM | Gravity.RIGHT; params.x = offset; params.y = display.getHeight() - y - (isStartButton ? 0 : offset); break; case "top_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = isStartButton ? 0 : x; params.y = offset; break; case "top_vertical_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = offset; params.y = isStartButton ? 0 : y - statusBarHeight; break; case "top_right": params.gravity = Gravity.TOP | Gravity.RIGHT; params.x = display.getWidth() - x; params.y = offset; break; case "top_vertical_right": params.gravity = Gravity.TOP | Gravity.RIGHT; params.x = offset; params.y = isStartButton ? 0 : y - statusBarHeight; break; } } params.width = getResources().getDimensionPixelSize(R.dimen.context_menu_width); params.dimAmount = 0; getWindow().setAttributes(params); View view = findViewById(android.R.id.list); if (view != null) view.setPadding(0, 0, 0, 0); generateMenu(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.farmerbb.taskbar.START_MENU_APPEARING"); intentFilter.addAction("com.farmerbb.taskbar.DASHBOARD_APPEARING"); LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver, intentFilter); }
From source file:com.landenlabs.all_UiDemo.frag.ImageScalesFrag.java
private void setScaledVector(ImageView imageView, int imageRes) { Drawable rawDrawable;//w ww. j ava2 s . co m if (Build.VERSION.SDK_INT >= 21) { rawDrawable = getResources().getDrawable(imageRes, getTheme()); } else { rawDrawable = getResources().getDrawable(imageRes); } Drawable drawable = rawDrawable.mutate(); /* int pad = 50; drawable.setBounds(0, pad, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); */ // ScaleDrawable does nothing !!!! if (false) { ScaleDrawable scaleDrawable = new ScaleDrawable(rawDrawable, Gravity.TOP | Gravity.LEFT, 2.0f, 0.8f); scaleDrawable.setLevel(8000); drawable = scaleDrawable.getDrawable(); } if (false) { int tintColor = 0x80ff0000; ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] {} }, new int[] { tintColor }); drawable = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTintList(drawable, colorStateList); DrawableCompat.setTintMode(drawable, PorterDuff.Mode.MULTIPLY); } //imageView.setScaleType(ImageView.ScaleType.CENTER); imageView.setImageDrawable(drawable); // imageView.setImageDrawable(null); // imageView.setBackgroundDrawable(drawable); }
From source file:cn.edu.sdu.online.activity.FragmentTabsPager.java
private void createView() { floatView = new FloatView(getApplicationContext()); floatView.setOnClickListener(new imageviewListener()); floatView.setImageResource(R.drawable.releasetask); windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); windowManagerParams = ((FloatApplication) getApplication()).getWindowParams(); windowManagerParams.type = LayoutParams.TYPE_PHONE; windowManagerParams.format = PixelFormat.RGBA_8888; windowManagerParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_FOCUSABLE; windowManagerParams.gravity = Gravity.LEFT | Gravity.TOP; windowManagerParams.x = 8;//from w w w . j a v a 2 s . c om windowManagerParams.y = height - 260; windowManagerParams.width = LayoutParams.WRAP_CONTENT; windowManagerParams.height = LayoutParams.WRAP_CONTENT; windowManager.addView(floatView, windowManagerParams); }