当前位置: 首页>>代码示例>>Java>>正文


Java Gravity.TOP属性代码示例

本文整理汇总了Java中android.view.Gravity.TOP属性的典型用法代码示例。如果您正苦于以下问题:Java Gravity.TOP属性的具体用法?Java Gravity.TOP怎么用?Java Gravity.TOP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.Gravity的用法示例。


在下文中一共展示了Gravity.TOP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initCross

private void initCross(Context context) {
    ImageView cross = new ImageView(context);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.TOP | Gravity.END;
    cross.setLayoutParams(layoutParams);
    cross.setImageDrawable(completeIcon);

    this.addView(cross);

    cross.setOnClickListener(new OnClickListener() {
        public final void onClick(View it) {
            if (TutorialLayout.this.tutorialListener != null) {
                TutorialLayout.this.tutorialListener.onCompleteAll();
            }
        }
    });
}
 
开发者ID:Popalay,项目名称:Tutors,代码行数:17,代码来源:TutorialLayout.java

示例2: setupStatusBarView

public static void setupStatusBarView(Activity activity, ViewGroup decorViewGroup, boolean on, int colorRes) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window win = activity.getWindow();
        setTranslucentStatus(win, on);
        View mStatusBarTintView = new View(activity);
        int mStatusBarHeight = 0;
        int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            mStatusBarHeight = activity.getResources().getDimensionPixelSize(resourceId);
        }
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mStatusBarHeight);
        params.gravity = Gravity.TOP;
        mStatusBarTintView.setLayoutParams(params);
        mStatusBarTintView.setBackgroundResource(colorRes);
        mStatusBarTintView.setVisibility(View.VISIBLE);
        decorViewGroup.addView(mStatusBarTintView);
    }
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:18,代码来源:StatusBarCompat.java

示例3: init

public static void init(Context context) {
    sWindowManager = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
    sLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
            VERSION.SDK_INT >= VERSION_CODES.M ? LayoutParams.TYPE_SYSTEM_ALERT : LayoutParams.TYPE_TOAST,
            0x18, PixelFormat.TRANSLUCENT);
    sLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    sView = LayoutInflater.from(context.getApplicationContext()).inflate(R.layout.view_tracker_window, null);
}
 
开发者ID:DysaniazzZ,项目名称:TopActivity,代码行数:8,代码来源:TrackerWindowUtil.java

示例4: onLayout

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    final View child = getChildAt(0);

    if (child == null) {
        return;
    }

    if (mGravity == Gravity.TOP) {
        child.layout(0, 0, getMeasuredWidth(), child.getMeasuredHeight());
    } else {
        child.layout(0, getMeasuredHeight() - child.getMeasuredHeight(), getMeasuredWidth(), getMeasuredHeight());
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:14,代码来源:DragSortItemView.java

示例5: onClick

@Override
public void onClick(final View v) {

    if (currentLookForWid.getText().equals(" ")) {
        v.startAnimation(notItAnim);
        return;
    }

    String symv = (String)v.getTag();

    TextView wid2 = activeSyms.get(current);
    if (wid2==null) return;

    String symw = (String)wid2.getTag();

    if (symv.equals(symw)) {

        Log.d("Doda", "Found " + symv.codePointAt(0));
        v.setAlpha(.6f);
        v.startAnimation(wasItAnim);


        final ImageView blow = new ImageView(this);
        blow.setBackgroundResource(R.drawable.explosion);

        Point location = symPoints.get((TextView)v);
        float fac = 1.25f;

        score += Math.max(100, 5000 - (System.currentTimeMillis() - findTime)) * (backgroundImage?1.5:1);

        int msize = spToPx((int)(mMode.getMaxIconSize(bsize)*fac));
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(msize, msize);
        lp.setMargins(location.x - (int)(mMode.getMaxIconSize(bsize)*fac/2), location.y - (int)(mMode.getMaxIconSize(bsize)*fac/2), 0, 0);
        lp.gravity = Gravity.START | Gravity.TOP;


        blow.setLayoutParams(lp);
        mSoundEffects.playPlode();

        v.clearAnimation();

        mMainScreen.removeView(v);
        activeSyms.set(current, null);
        mMainScreen.addView(blow);

        AnimationDrawable ad = ((AnimationDrawable) blow.getBackground());
        int time = ad.getNumberOfFrames() * ad.getDuration(0);
        ad.start();
        showNext(false);

        mMainScreen.postDelayed(new Runnable() {
            @Override
            public void run() {
                mMainScreen.removeView(blow);
            }
        }, time + 20);

    } else {

        v.startAnimation(notItAnim);
        if (mMode.isTimed()) {
            startTime -= 5000;
            showMessage(getString(R.string.miss_penalty));
        }

    }

}
 
开发者ID:quaap,项目名称:DodaTheExploda,代码行数:68,代码来源:MainActivity.java

示例6: setMsgMargin

/**
 * 设置提示红点偏移,注意
 * 1.控件为固定高度:参照点为tab内容的右上角
 * 2.控件高度不固定(WRAP_CONTENT):参照点为tab内容的右上角,此时高度已是红点的最高显示范围,所以这时bottomPadding其实就是topPadding
 */
public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
    if (position >= mTabCount) {
        position = mTabCount - 1;
    }
    View tabView = mTabsContainer.getChildAt(position);
    MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
    if (tipView != null) {
        TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
        mTextPaint.setTextSize(mTextsize);
        float textWidth = mTextPaint.measureText(tv_tab_title.getText().toString());
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        MarginLayoutParams lp = (MarginLayoutParams) tipView.getLayoutParams();

        float iconH = mIconHeight;
        float margin = 0;
        if (mIconVisible) {
            if (iconH <= 0) {
                iconH = mContext.getResources().getDrawable(mTabEntitys.get(position).getTabSelectedIcon()).getIntrinsicHeight();
            }
            margin = mIconMargin;
        }

        if (mIconGravity == Gravity.TOP || mIconGravity == Gravity.BOTTOM) {
            lp.leftMargin = dp2px(leftPadding);
            lp.topMargin = mHeight > 0 ? (int) (mHeight - textHeight - iconH - margin) / 2 - dp2px(bottomPadding) : dp2px(bottomPadding);
        } else {
            lp.leftMargin = dp2px(leftPadding);
            lp.topMargin = mHeight > 0 ? (int) (mHeight - Math.max(textHeight, iconH)) / 2 - dp2px(bottomPadding) : dp2px(bottomPadding);
        }

        tipView.setLayoutParams(lp);
    }
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:38,代码来源:CommonTabLayout.java

示例7: init

public static void init(final Context context){
    sWindowManager = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
    sWindowLayoutParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            Build.VERSION.SDK_INT > Build.VERSION_CODES.N?
                    WindowManager.LayoutParams.TYPE_PHONE: WindowManager.LayoutParams.TYPE_TOAST,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT
    );
    sWindowLayoutParams.gravity = Gravity.TOP + Gravity.RIGHT;
    sView = LayoutInflater.from(context).inflate(R.layout.layout_floating_window,null);
}
 
开发者ID:jiangkang,项目名称:KTools,代码行数:13,代码来源:FloatingWindow.java

示例8: setTextImage

/**
 * 设置TextViewImage,方向个数必须和res个数相同
 *
 * @param viewId  View ID
 * @param gravity {@link Gravity#START}|{@link Gravity#TOP}|{@link Gravity#END}|{@link Gravity#BOTTOM}
 * @param resId   资源ID
 */
public void setTextImage(@IdRes int viewId, int gravity, @DrawableRes int... resId) {
    int index = 0;

    // 初始化Drawable
    int length = resId.length;
    Drawable[] initDrawables = new Drawable[length];
    for (int i = 0; i < length; i++) {
        Drawable drawable = ContextCompat.getDrawable(getContext(), resId[i]);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        initDrawables[i] = drawable;
    }

    // 设置Drawable
    Drawable[] setDrawables = new Drawable[4];
    if ((gravity & Gravity.START) == Gravity.START) {
        setDrawables[0] = initDrawables[index++];
    }
    if ((gravity & Gravity.TOP) == Gravity.TOP) {
        setDrawables[1] = initDrawables[index++];
    }
    if ((gravity & Gravity.END) == Gravity.END) {
        setDrawables[2] = initDrawables[index++];
    }
    if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        setDrawables[3] = initDrawables[index];
    }
    TextView tv = getView(viewId);
    tv.setCompoundDrawables(setDrawables[0], setDrawables[1], setDrawables[2], setDrawables[3]);
}
 
开发者ID:sswukang,项目名称:RvAdapter,代码行数:36,代码来源:BaseViewHolder.java

示例9: createPopupLayout

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;
    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("DiscreteSeekBar Indicator:" + Integer.toHexString(hashCode()));

    return p;
}
 
开发者ID:dmllr,项目名称:IdealMedia,代码行数:14,代码来源:PopupIndicator.java

示例10: getSnappedPosition

int getSnappedPosition(RecyclerView recyclerView) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();

    if (layoutManager instanceof LinearLayoutManager) {
        if (mGravity == Gravity.START || mGravity == Gravity.TOP) {
            return ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
        } else if (mGravity == Gravity.END || mGravity == Gravity.BOTTOM) {
            return ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition();
        }
    }

    return RecyclerView.NO_POSITION;

}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:14,代码来源:GravitySnapHelper.java

示例11: setupStatusBarView

private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {
    mStatusBarTintView = new View(context);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
    params.gravity = Gravity.TOP;
    if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {
        params.rightMargin = mConfig.getNavigationBarWidth();
    }
    mStatusBarTintView.setLayoutParams(params);
    mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
    mStatusBarTintView.setVisibility(View.GONE);
    decorViewGroup.addView(mStatusBarTintView);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SystemBarTintManager.java

示例12: initWindowParams

private void initWindowParams() {
    mWindowManager = (WindowManager) getApplication().getSystemService(WINDOW_SERVICE);
    mWindowParams = new WindowManager.LayoutParams();
    mWindowParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    mWindowParams.format = PixelFormat.TRANSLUCENT;
    mWindowParams.flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;

    mWindowParams.gravity = Gravity.START | Gravity.TOP;
    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
}
 
开发者ID:frowhy,项目名称:Hold,代码行数:13,代码来源:PpwButtonService.java

示例13: show

public void show() {
    if (mState >= DESTROYING) {

        return;
    }

    if (mState == UNCREATED) {

        create();
    }

    if (!mOutsideTouchable) {

        addMask();
    }

    if (mState == CREATED) {

        WindowManager windowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE);
        WindowManager.LayoutParams windowParams = new WindowManager.LayoutParams();

        windowParams.gravity = Gravity.TOP | Gravity.LEFT;
        windowParams.x = 0;
        windowParams.y = 0;
        windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        windowParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        windowParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
        windowParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        windowParams.format = PixelFormat.TRANSLUCENT;
        windowParams.windowAnimations = 0;
        windowManager.addView(mRootLayout, windowParams);
    }
    mState = VISIBLE;
    mRootLayout.setVisibility(View.VISIBLE);
    mRootLayout.show();

    startCountDown(mDuration);
}
 
开发者ID:316boss,项目名称:TopNotification,代码行数:40,代码来源:TopNotification.java

示例14: getYBasedOnGravity

private int getYBasedOnGravity(int height){
    int [] pos = new int[2];
    mHighlightedView.getLocationInWindow(pos);
    int y = pos[1];
    if((mPointer.mGravity & Gravity.BOTTOM) == Gravity.BOTTOM){
        return y+mHighlightedView.getHeight()-height;
    } else if ((mPointer.mGravity & Gravity.TOP) == Gravity.TOP) {
        return y;
    }else { // this is center
        return y+mHighlightedView.getHeight()/2-height/2;
    }
}
 
开发者ID:AmulaySoftGroup,项目名称:TaBeTa,代码行数:12,代码来源:TourGuide.java

示例15: UserCell

public UserCell(Context context, int padding, int checkbox, boolean admin) {
    super(context);

    avatarDrawable = new AvatarDrawable();

    avatarImageView = new BackupImageView(context);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
    int avLeftMargin=LocaleController.isRTL ? 0 : 0 + padding;
    int avRightMargin=LocaleController.isRTL ? 0 + padding : 0;
    int gravity=(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
    addView(avatarImageView, LayoutHelper.createFrame(48, 48, gravity, avLeftMargin, 8, avRightMargin, 0));

    mutualView=new ImageView(context);
    mutualView.setVisibility(GONE);
    addView(mutualView, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL,
            LocaleController.isRTL ? 16 : 0
            ,
            0
            ,
            /*LocaleController.isRTL ?
                    AndroidUtilities.dp(65f) + avLeftMargin
                    : avLeftMargin - AndroidUtilities.dp(25f)*/
            LocaleController.isRTL ? 0 : 16
            , 0));
    mutualView.setImageResource(R.drawable.party);
    mutualView.setColorFilter(SkinMan.currentSkin.actionbarColor());



    nameTextView = new SimpleTextView(context);
    nameTextView.setTextColor(0xff212121);
    nameTextView.setTextSize(17);
    nameTextView.setTypeface(FontManager.instance().getTypeface());
    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 + (checkbox == 2 ? 18 : 0) : (68 + padding), 11.5f, LocaleController.isRTL ? (68 + padding) : 28 + (checkbox == 2 ? 18 : 0), 0));

    statusTextView = new SimpleTextView(context);
    statusTextView.setTextSize(14);
    statusTextView.setTypeface(FontManager.instance().getTypeface());
    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 : (68 + padding), 34.5f, LocaleController.isRTL ? (68 + padding) : 28, 0));

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setVisibility(GONE);
    addView(imageView, LayoutHelper.createFrame(LayoutParams.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 0 : 16, 0, LocaleController.isRTL ? 16 : 0, 0));

    if (checkbox == 2) {
        checkBoxBig = new CheckBoxSquare(context);
        addView(checkBoxBig, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 19 : 0, 0, LocaleController.isRTL ? 0 : 19, 0));
    } else if (checkbox == 1) {
        checkBox = new CheckBox(context, R.drawable.round_check2);
        checkBox.setVisibility(INVISIBLE);
        addView(checkBox, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 37 + padding, 38, LocaleController.isRTL ? 37 + padding : 0, 0));
    }

    if (admin) {
        adminImage = new ImageView(context);
        addView(adminImage, LayoutHelper.createFrame(16, 16, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 24 : 0, 13.5f, LocaleController.isRTL ? 0 : 24, 0));
    }
    statusOnlineColor= SkinMan.currentSkin.actionbarColor();
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:62,代码来源:UserCell.java


注:本文中的android.view.Gravity.TOP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。