类android.view.Gravity源码实例Demo

下面列出了怎么用android.view.Gravity的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: VideoChatHeads   文件: VideoChatHeadService.java
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);
    }
 
源代码2 项目: zhangshangwuda   文件: ImageViewFromUrl.java
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);
}
 
源代码3 项目: Dashchan   文件: DrawerLayout.java
@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();
}
 
@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();
}
 
@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);
	}
}
 
源代码6 项目: actor-platform   文件: PacksAdapter.java
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);
        }
    });
}
 
源代码7 项目: Game-of-Thrones   文件: MessageRenderer.java
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);
}
 
源代码8 项目: WanAndroid   文件: CustomBanner.java
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;
}
 
源代码9 项目: Shield   文件: LoadingStatusAgent.java
@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;
}
 
源代码10 项目: android_9.0.0_r45   文件: InputMethodService.java
@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);
}
 
/**
 * 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());
        }
    });
}
 
源代码12 项目: status-bar-compat   文件: StatusBarKitkatImpl.java
@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);
}
 
源代码13 项目: CircleIndicator   文件: BaseCircleIndicator.java
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);
}
 
源代码14 项目: KA27   文件: MainActivity.java
/**
 * 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();
}
 
源代码15 项目: ShowcaseView   文件: ShowcaseViewBuilder.java
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;
}
 
源代码16 项目: Noyze   文件: VolumeBarPanel.java
@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;
}
 
源代码17 项目: Telegram-FOSS   文件: SimpleTextView.java
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;
    }
}
 
源代码18 项目: CoreModule   文件: FooterView.java
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);
}
 
源代码19 项目: Applozic-Android-SDK   文件: ChannelInfoActivity.java
@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);
        }
    }
}
 
源代码20 项目: Musicoco   文件: OptionsDialog.java
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());
}
 
源代码21 项目: Telegram   文件: ChatAttachAlertContactsLayout.java
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));
}
 
源代码22 项目: PictureSelector   文件: AspectRatioTextView.java
@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();
}
 
源代码23 项目: Android   文件: MaterialBadgeTextView.java
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();
}
 
源代码24 项目: Noyze   文件: iOSVolumePanel.java
@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;
}
 
源代码25 项目: hintcase   文件: SimpleHintContentHolder.java
@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;
}
 
@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);
}
 
源代码27 项目: 920-text-editor-v2   文件: TabViewPager.java
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();
}
 
@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);
    }
}
 
源代码29 项目: SoloPi   文件: PermissionDialogActivity.java
/**
 * 设置窗体信息
 */
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);
}
 
源代码30 项目: Focus   文件: DatabaseHelper.java
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;
}
 
 类所在包
 同包方法