android.view.Gravity Java Examples
The following examples show how to use
android.view.Gravity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: VideoChatHeads Author: TakeoffAndroid File: VideoChatHeadService.java License: The Unlicense | 6 votes |
private void addCloseView() { liClose = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); // add close view ImageView centered on the bottom of the screen mCloseViewParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); mCloseViewParams.gravity = Gravity.BOTTOM | Gravity.CENTER; mCloseViewParams.height = 400; mCloseViewParams.width = WindowManager.LayoutParams.MATCH_PARENT; closeView = liClose.inflate(R.layout.view_layout_close, null); ivCloseView = (ImageView) closeView.findViewById(R.id.img_close); mCloseViewParams.x = 0; mCloseViewParams.y = 0; mWindowManager.addView(closeView, mCloseViewParams); }
Example #2
Source Project: zhangshangwuda Author: Consoar File: ImageViewFromUrl.java License: Apache License 2.0 | 6 votes |
private void init(Context context) { mContext=context; // init layout params LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; // loading progress bar mLoading = new ProgressBar(context); mLoading.setLayoutParams(params); mLoading.setProgress(android.R.attr.progressBarStyleSmall); // image view to display the bitmap mImage = new ImageView(context); mImage.setLayoutParams(params); removeAllViews(); addView(mLoading); addView(mImage); }
Example #3
Source Project: Dashchan Author: Mishiranu File: DrawerLayout.java License: Apache License 2.0 | 6 votes |
@Override public void onViewReleased(View releasedChild, float xvel, float yvel) { // Offset is how open the drawer is, therefore left/right values // are reversed from one another. final float offset = getDrawerViewOffset(releasedChild); final int childWidth = releasedChild.getWidth(); int left; if (checkDrawerViewAbsoluteGravity(releasedChild, Gravity.LEFT)) { left = xvel > 0 || xvel == 0 && offset > 0.5f ? 0 : -childWidth; } else { final int width = getWidth(); left = xvel < 0 || xvel == 0 && offset > 0.5f ? width - childWidth : width; } mDragger.settleCapturedViewAt(left, releasedChild.getTop()); invalidate(); }
Example #4
Source Project: 920-text-editor-v2 Author: jecelyin File: TranslucentDrawerLayout.java License: Apache License 2.0 | 6 votes |
@Override public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) { float offset; final int childWidth = changedView.getWidth(); // This reverses the positioning shown in onLayout. if (checkDrawerViewAbsoluteGravity(changedView, Gravity.LEFT)) { offset = (float) (childWidth + left) / childWidth; } else { final int width = getWidth(); offset = (float) (width - left) / childWidth; } setDrawerViewOffset(changedView, offset); changedView.setVisibility(offset == 0 ? INVISIBLE : VISIBLE); invalidate(); }
Example #5
Source Project: UltimateAndroid Author: cymcsg File: TextRoundCornerProgressBar.java License: Apache License 2.0 | 6 votes |
@SuppressLint("NewApi") public TextRoundCornerProgressBar(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { isProgressBarCreated = false; isProgressSetBeforeDraw = false; isMaxProgressSetBeforeDraw = false; isBackgroundColorSetBeforeDraw = false; isProgressColorSetBeforeDraw = false; LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.round_corner_progress_bar_round_corner_with_text_layout, this); setup(context, attrs); isProgressBarCreated = true; } else { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setBackground(new ColorDrawable(Color.parseColor("#CCCCCC"))); } else { setBackgroundColor(Color.parseColor("#CCCCCC")); } setGravity(Gravity.CENTER); setPadding(0, (int)dp2px(5), 0, (int)dp2px(5)); TextView tv = new TextView(context); tv.setText("TextRoundCornerProgressBar"); addView(tv); } }
Example #6
Source Project: actor-platform Author: actorapp File: PacksAdapter.java License: GNU Affero General Public License v3.0 | 6 votes |
public StickerViewHolder(Context context, FrameLayout fl) { super(fl); this.fl = fl; sv = new StickerView(context); int padding = Screen.dp(2); sv.setPadding(padding, padding, padding, padding); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(packsSwitchContainer.getHeight(), packsSwitchContainer.getHeight(), Gravity.CENTER); fl.addView(sv, params); fl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int oldSelected = selectedPostion; selectedPostion = position; notifyItemChanged(oldSelected); notifyItemChanged(selectedPostion); stickersAdapter.scrollToSticker(s); } }); }
Example #7
Source Project: Game-of-Thrones Author: tonilopezmr File: MessageRenderer.java License: Apache License 2.0 | 6 votes |
private void renderMessageFromOthers(Message message) { User user = message.getUser(); rootView.setGravity(Gravity.BOTTOM | Gravity.START); displayNameTextView.setVisibility(View.VISIBLE); avatarImageView.setVisibility(View.VISIBLE); imageLoader.builder() .load(user.getImageUrl()) .placeHolder(AppCompatDrawableManager.get().getDrawable(avatarImageView.getContext(), R.drawable.ned_head_light)) .into(avatarImageView) .circle() .show(); displayNameTextView.setText(user.getName()); displayPayLoad(message.getPayload()); messageContainer.setBackgroundResource(R.drawable.background_message_from_others); }
Example #8
Source Project: WanAndroid Author: CoderLengary File: CustomBanner.java License: Apache License 2.0 | 6 votes |
private CustomBanner setIndicatorGravity(int type) { switch (type) { case BannerConfig.LEFT: indicatorGravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; break; case BannerConfig.CENTER: indicatorGravity = Gravity.CENTER; break; case BannerConfig.RIGHT: indicatorGravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; break; default: indicatorGravity = Gravity.CENTER; } return this; }
Example #9
Source Project: Shield Author: Meituan-Dianping File: LoadingStatusAgent.java License: MIT License | 6 votes |
@Override public View onCreateView(ViewGroup parent, int viewType) { LinearLayout rootView = new LinearLayout(mContext); rootView.setOrientation(LinearLayout.VERTICAL); rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = ViewUtils.dip2px(getContext(), 30); itemViewHolder = new ItemViewHolder(); TextView textView = new TextView(mContext); textView.setHeight(ViewUtils.dip2px(getContext(), 50)); textView.setGravity(Gravity.CENTER_VERTICAL); itemViewHolder.textView = textView; rootView.addView(textView, params); rootView.setTag(itemViewHolder); return rootView; }
Example #10
Source Project: android_9.0.0_r45 Author: lulululbj File: InputMethodService.java License: Apache License 2.0 | 6 votes |
@Override public void onCreate() { mTheme = Resources.selectSystemTheme(mTheme, getApplicationInfo().targetSdkVersion, android.R.style.Theme_InputMethod, android.R.style.Theme_Holo_InputMethod, android.R.style.Theme_DeviceDefault_InputMethod, android.R.style.Theme_DeviceDefault_InputMethod); super.setTheme(mTheme); super.onCreate(); mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); mSettingsObserver = SettingsObserver.createAndRegister(this); // If the previous IME has occupied non-empty inset in the screen, we need to decide whether // we continue to use the same size of the inset or update it mShouldClearInsetOfPreviousIme = (mImm.getInputMethodWindowVisibleHeight() > 0); mInflater = (LayoutInflater)getSystemService( Context.LAYOUT_INFLATER_SERVICE); mWindow = new SoftInputWindow(this, "InputMethod", mTheme, null, null, mDispatcherState, WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false); // For ColorView in DecorView to work, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS needs to be set // by default (but IME developers can opt this out later if they want a new behavior). mWindow.getWindow().setFlags( FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); initViews(); mWindow.getWindow().setLayout(MATCH_PARENT, WRAP_CONTENT); }
Example #11
Source Project: android-SwipeRefreshMultipleViews Author: googlearchive File: SampleTests.java License: Apache License 2.0 | 6 votes |
/** * Test that swiping on the empty view triggers a refresh. */ public void testSwipingEmptyView() { // Given a SwipeRefreshLayout which is displaying the empty view // When the swipe refresh layout is dragged TouchUtils.dragViewBy(this, mSwipeRefreshLayout, Gravity.CENTER, 0, Math.round(mSwipeRefreshLayout.getHeight() * 0.4f)); // Then the SwipeRefreshLayout should be refreshing getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { assertTrue(mSwipeRefreshLayout.isRefreshing()); } }); }
Example #12
Source Project: status-bar-compat Author: msdx File: StatusBarKitkatImpl.java License: Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) @Override public void setStatusBarColor(Window window, int color) { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); ViewGroup decorViewGroup = (ViewGroup) window.getDecorView(); View statusBarView = decorViewGroup.findViewWithTag(STATUS_BAR_VIEW_TAG); if (statusBarView == null) { statusBarView = new StatusBarView(window.getContext()); statusBarView.setTag(STATUS_BAR_VIEW_TAG); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.TOP; statusBarView.setLayoutParams(params); decorViewGroup.addView(statusBarView); } statusBarView.setBackgroundColor(color); StatusBarCompat.internalSetFitsSystemWindows(window, true); }
Example #13
Source Project: CircleIndicator Author: ongakuer File: BaseCircleIndicator.java License: Apache License 2.0 | 6 votes |
public void initialize(Config config) { int miniSize = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_INDICATOR_WIDTH, getResources().getDisplayMetrics()) + 0.5f); mIndicatorWidth = (config.width < 0) ? miniSize : config.width; mIndicatorHeight = (config.height < 0) ? miniSize : config.height; mIndicatorMargin = (config.margin < 0) ? miniSize : config.margin; mAnimatorOut = createAnimatorOut(config); mImmediateAnimatorOut = createAnimatorOut(config); mImmediateAnimatorOut.setDuration(0); mAnimatorIn = createAnimatorIn(config); mImmediateAnimatorIn = createAnimatorIn(config); mImmediateAnimatorIn.setDuration(0); mIndicatorBackgroundResId = (config.backgroundResId == 0) ? R.drawable.white_radius : config.backgroundResId; mIndicatorUnselectedBackgroundResId = (config.unselectedBackgroundId == 0) ? config.backgroundResId : config.unselectedBackgroundId; setOrientation(config.orientation == VERTICAL ? VERTICAL : HORIZONTAL); setGravity(config.gravity >= 0 ? config.gravity : Gravity.CENTER); }
Example #14
Source Project: KA27 Author: fgl27 File: MainActivity.java License: Apache License 2.0 | 6 votes |
/** * Dialog which asks the user to enter his password * * @param password current encoded password */ private void askPassword(final String password) { LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.setPadding(30, 20, 30, 20); final AppCompatEditText mPassword = new AppCompatEditText(this); mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassword.setHint(getString(R.string.password)); linearLayout.addView(mPassword); new AlertDialog.Builder(this).setView(linearLayout).setCancelable(false) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (mPassword.getText().toString().equals(Utils.decodeString(password))) new Task().execute(); else { Utils.toast(getString(R.string.password_wrong), MainActivity.this); finish(); } } }).show(); }
Example #15
Source Project: ShowcaseView Author: outlander24 File: ShowcaseViewBuilder.java License: Apache License 2.0 | 6 votes |
public ShowcaseViewBuilder addCustomView(int layoutId, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) { View view = LayoutInflater.from(mActivity).inflate(layoutId, null); LinearLayout linearLayout = new LinearLayout(mActivity); linearLayout.addView(view); linearLayout.setGravity(Gravity.CENTER); DisplayMetrics metrics = new DisplayMetrics(); mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics); Rect rect = new Rect(); rect.set(0, 0, metrics.widthPixels, metrics.heightPixels); int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), MeasureSpec.EXACTLY); linearLayout.measure(widthSpec, heightSpec); mCustomView.add(linearLayout); mCustomViewGravity.add(gravity); mCustomViewLeftMargins.add(leftMargin); mCustomViewTopMargins.add(topMargin); mCustomViewRightMargins.add(rightMargin); mCustomViewBottomMargins.add(bottomMargin); return this; }
Example #16
Source Project: Noyze Author: Tombarr File: VolumeBarPanel.java License: Apache License 2.0 | 6 votes |
@Override public WindowManager.LayoutParams getWindowLayoutParams() { int flags = (WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED ); WindowManager.LayoutParams WPARAMS = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, 0, 0, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, flags, PixelFormat.TRANSLUCENT); WPARAMS.windowAnimations = android.R.style.Animation_Dialog; WPARAMS.packageName = getContext().getPackageName(); WPARAMS.setTitle(TAG); WPARAMS.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT; WPARAMS.gravity = (Gravity.FILL_HORIZONTAL | Gravity.TOP); WPARAMS.screenBrightness = WPARAMS.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; return WPARAMS; }
Example #17
Source Project: Telegram-FOSS Author: Telegram-FOSS-Team File: SimpleTextView.java License: GNU General Public License v2.0 | 6 votes |
private void calcOffset(int width) { if (layout.getLineCount() > 0) { textWidth = (int) Math.ceil(layout.getLineWidth(0)); textHeight = layout.getLineBottom(0); if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.CENTER_HORIZONTAL) { offsetX = (width - textWidth) / 2; } else if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) { offsetX = -(int) layout.getLineLeft(0); } else if (layout.getLineLeft(0) == 0) { offsetX = width - textWidth; } else { offsetX = -AndroidUtilities.dp(8); } offsetX += getPaddingLeft(); textDoesNotFit = textWidth > width; } }
Example #18
Source Project: CoreModule Author: kymjs File: FooterView.java License: Apache License 2.0 | 6 votes |
public void init() { this.setOrientation(HORIZONTAL); this.setGravity(Gravity.CENTER); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; params.height = dip2px(23); this.setLayoutParams(params); progressBar.setIndeterminate(true); LayoutParams progressBarparams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarparams.width = progressBarparams.height = dip2px(22); progressBar.setLayoutParams(progressBarparams); LayoutParams textViewparams = new LayoutParams(LayoutParams.WRAP_CONTENT, dip2px(20)); textView.setTextColor(0xff666666); textView.setTextSize(16); textView.setLayoutParams(textViewparams); this.addView(progressBar); this.addView(textView); }
Example #19
Source Project: Applozic-Android-SDK Author: AppLozic File: ChannelInfoActivity.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void onPostExecute(Long aLong) { super.onPostExecute(aLong); if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } if (!Utils.isInternetAvailable(context)) { Toast toast = Toast.makeText(context, getString(R.string.you_dont_have_any_network_access_info), Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (SUCCESS.equals(responseForRemove) && contactsAdapter != null) { if (channelUserMapperList != null && channelUserMapperList.size() > 0) { channelUserMapperList.remove(channelUserMapper); contactsAdapter.notifyDataSetChanged(); Helper.getListViewSize(mainListView); } } }
Example #20
Source Project: Musicoco Author: DuanJiaNing File: OptionsDialog.java License: Apache License 2.0 | 6 votes |
public OptionsDialog(Activity activity) { this.activity = activity; this.mDialog = new Dialog(activity, R.style.BottomDialog); mDialog.getWindow().setGravity(Gravity.BOTTOM); mDialog.getWindow().setWindowAnimations(R.style.BottomDialog_Animation); mDialog.setCanceledOnTouchOutside(true); View view = LayoutInflater.from(activity).inflate(R.layout.options_container, null); listView = (ListView) view.findViewById(R.id.options_list); contentView = (LinearLayout) view.findViewById(R.id.options_container); titleText = (TextView) view.findViewById(R.id.options_title); divide = view.findViewById(R.id.options_divide); mDialog.setContentView(view); listView.post(new Runnable() { @Override public void run() { setDialogHeight(); } }); Utils.hideNavAndStatus(mDialog.getWindow().getDecorView()); }
Example #21
Source Project: Telegram Author: DrKLO File: ChatAttachAlertContactsLayout.java License: GNU General Public License v2.0 | 6 votes |
public UserCell(Context context) { super(context); avatarDrawable = new AvatarDrawable(); avatarImageView = new BackupImageView(context); avatarImageView.setRoundRadius(AndroidUtilities.dp(23)); addView(avatarImageView, LayoutHelper.createFrame(46, 46, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 14, 9, LocaleController.isRTL ? 14 : 0, 0)); nameTextView = new SimpleTextView(context); nameTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameTextView.setTextSize(16); nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : 72, 12, LocaleController.isRTL ? 72 : 28, 0)); statusTextView = new SimpleTextView(context); statusTextView.setTextSize(13); statusTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray2)); statusTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView(statusTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : 72, 36, LocaleController.isRTL ? 72 : 28, 0)); }
Example #22
Source Project: PictureSelector Author: LuckSiege File: AspectRatioTextView.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") private void init(@NonNull TypedArray a) { setGravity(Gravity.CENTER_HORIZONTAL); mAspectRatioTitle = a.getString(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_title); mAspectRatioX = a.getFloat(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_x, CropImageView.SOURCE_IMAGE_ASPECT_RATIO); mAspectRatioY = a.getFloat(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_y, CropImageView.SOURCE_IMAGE_ASPECT_RATIO); if (mAspectRatioX == CropImageView.SOURCE_IMAGE_ASPECT_RATIO || mAspectRatioY == CropImageView.SOURCE_IMAGE_ASPECT_RATIO) { mAspectRatio = CropImageView.SOURCE_IMAGE_ASPECT_RATIO; } else { mAspectRatio = mAspectRatioX / mAspectRatioY; } mDotSize = getContext().getResources().getDimensionPixelSize(R.dimen.ucrop_size_dot_scale_text_view); mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mDotPaint.setStyle(Paint.Style.FILL); setTitle(); int activeColor = getResources().getColor(R.color.ucrop_color_widget_active); applyActiveColor(activeColor); a.recycle(); }
Example #23
Source Project: Android Author: connectim File: MaterialBadgeTextView.java License: MIT License | 6 votes |
private void init(Context context, AttributeSet attrs) { setGravity(Gravity.CENTER); density = getContext().getResources().getDisplayMetrics().density; mShadowRadius = (int) (density * SHADOW_RADIUS); shadowYOffset = (int) (density * Y_OFFSET); shadowXOffset = (int) (density * X_OFFSET); basePadding = (mShadowRadius * 2); float textHeight = getTextSize(); float textWidth = textHeight / 4; diffWH = (int) (Math.abs(textHeight - textWidth) / 2); int horizontalPadding = basePadding + diffWH; setPadding(horizontalPadding, basePadding, horizontalPadding, basePadding); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MaterialBadgeTextView); backgroundColor = typedArray.getColor(R.styleable.MaterialBadgeTextView_android_background, Color.WHITE); borderColor = typedArray.getColor(R.styleable.MaterialBadgeTextView_mbtv_border_color, Color.TRANSPARENT); borderWidth = typedArray.getDimension(R.styleable.MaterialBadgeTextView_mbtv_border_width, 0); borderAlpha = typedArray.getFloat(R.styleable.MaterialBadgeTextView_mbtv_border_alpha, 1); ctType = typedArray.getInt(R.styleable.MaterialBadgeTextView_mbtv_type, DEFAULT_FILL_TYPE); typedArray.recycle(); }
Example #24
Source Project: Noyze Author: Tombarr File: iOSVolumePanel.java License: Apache License 2.0 | 6 votes |
@Override public WindowManager.LayoutParams getWindowLayoutParams() { int flags = (WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED ); WindowManager.LayoutParams WPARAMS = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, 0, 0, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, flags, PixelFormat.TRANSLUCENT); WPARAMS.windowAnimations = android.R.style.Animation_Dialog; WPARAMS.packageName = getContext().getPackageName(); WPARAMS.setTitle(TAG); WPARAMS.gravity = (Gravity.CENTER); WPARAMS.screenBrightness = WPARAMS.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; return WPARAMS; }
Example #25
Source Project: hintcase Author: Nescafemix File: SimpleHintContentHolder.java License: Apache License 2.0 | 6 votes |
@Override public View getView(Context context, final HintCase hintCase, ViewGroup parent) { FrameLayout.LayoutParams frameLayoutParamsBlock = getParentLayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, gravity, marginLeft, marginTop, marginRight, marginBottom); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setLayoutParams(frameLayoutParamsBlock); linearLayout.setGravity(Gravity.CENTER); linearLayout.setOrientation(LinearLayout.VERTICAL); if (contentTitle != null) { linearLayout.addView(getTextViewTitle(context)); } if (existImage()) { linearLayout.addView(getImage(context, imageView, imageResourceId)); } if (contentText != null) { linearLayout.addView(getTextViewDescription(context)); } return linearLayout; }
Example #26
Source Project: HelloTransactionAnimations Author: mengdd File: SecondActivity.java License: Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textView = new TextView(this); textView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); textView.setGravity(Gravity.CENTER); textView.setText("Activity Two"); textView.setBackgroundColor(Color.BLUE); setContentView(textView); }
Example #27
Source Project: 920-text-editor-v2 Author: jecelyin File: TabViewPager.java License: Apache License 2.0 | 5 votes |
public LayoutParams(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); gravity = a.getInteger(0, Gravity.TOP); a.recycle(); }
Example #28
Source Project: MaterialPreference Author: RikkaW File: ForegroundCheckTextView.java License: Apache License 2.0 | 5 votes |
@Override public void draw(@NonNull Canvas canvas) { super.draw(canvas); if (mForeground != null) { final Drawable foreground = mForeground; if (mForegroundBoundsChanged) { mForegroundBoundsChanged = false; final Rect selfBounds = mSelfBounds; final Rect overlayBounds = mOverlayBounds; final int w = getRight() - getLeft(); final int h = getBottom() - getTop(); if (mForegroundInPadding) { selfBounds.set(0, 0, w, h); } else { selfBounds.set(getPaddingLeft(), getPaddingTop(), w - getPaddingRight(), h - getPaddingBottom()); } Gravity.apply(mForegroundGravity, foreground.getIntrinsicWidth(), foreground.getIntrinsicHeight(), selfBounds, overlayBounds); foreground.setBounds(overlayBounds); } foreground.draw(canvas); } }
Example #29
Source Project: SoloPi Author: alipay File: PermissionDialogActivity.java License: Apache License 2.0 | 5 votes |
/** * 设置窗体信息 */ private void setupWindow() { WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams params = getWindow().getAttributes(); params.width = display.getWidth() - ContextUtil.dip2px(this, 48); getWindow().setGravity(Gravity.CENTER); }
Example #30
Source Project: Focus Author: ihewro File: DatabaseHelper.java License: GNU General Public License v3.0 | 5 votes |
public boolean execSQL(String sql, Object[] object) { try { db.execSQL(sql, object); } catch (SQLException e) { e.printStackTrace(); Toast toast = Toast.makeText(_context, e.getMessage(), Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return false; } return true; }