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


Java Gravity.CENTER_VERTICAL属性代码示例

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


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

示例1: getBodyBottom

private LinearLayout getBodyBottom() {
	LinearLayout llBottom = new LinearLayout(getContext());
	llBottom.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	String platform = String.valueOf(reqData.get("platform"));
	LinearLayout line = getAtLine(platform);
	if (line != null) {
		llBottom.addView(line);
	}

	// 字数统计
	tvCounter = new TextView(getContext());
	tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
	tvCounter.setTextColor(0xffcfcfcf);
	tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
	LinearLayout.LayoutParams lpCounter = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpCounter.gravity = Gravity.CENTER_VERTICAL;
	tvCounter.setLayoutParams(lpCounter);
	llBottom.addView(tvCounter);

	return llBottom;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:25,代码来源:EditPage.java

示例2: getBodyBottom

private LinearLayout getBodyBottom() {
	LinearLayout llBottom = new LinearLayout(getContext());
	llBottom.setLayoutParams(new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout line = getAtLine(platforms.get(0).getName());
	if (line != null) {
		llBottom.addView(line);
	}

	// Words counter
	tvCounter = new TextView(getContext());
	tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
	tvCounter.setTextColor(0xffcfcfcf);
	tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
	LayoutParams lpCounter = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpCounter.gravity = Gravity.CENTER_VERTICAL;
	tvCounter.setLayoutParams(lpCounter);
	llBottom.addView(tvCounter);

	return llBottom;
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:24,代码来源:EditPage.java

示例3: getItemViewType

@Override
public int getItemViewType(int position) {
    Snap snap = mSnaps.get(position);
    switch (snap.getGravity()) {
        case Gravity.CENTER_VERTICAL:
            return VERTICAL;
        case Gravity.CENTER_HORIZONTAL:
            return HORIZONTAL;
        case Gravity.START:
            return HORIZONTAL;
        case Gravity.TOP:
            return VERTICAL;
        case Gravity.END:
            return HORIZONTAL;
        case Gravity.BOTTOM:
            return VERTICAL;
    }
    return HORIZONTAL;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SnapAdapter.java

示例4: load

public static String load(String text, final AdvancedDisplay parent, final int pos) {
    final CalculatorEditText et = new CalculatorEditText(parent);
    et.setText(text);
    et.setSelection(0);
    if(parent.mKeyListener != null) et.setKeyListener(parent.mKeyListener);
    if(parent.mFactory != null) et.setEditableFactory(parent.mFactory);
    et.setBackgroundResource(android.R.color.transparent);
    et.setTextAppearance(parent.getContext(), R.style.display_style);
    et.setPadding(5, 0, 5, 0);
    et.setEnabled(parent.isEnabled());
    AdvancedDisplay.LayoutParams params = new AdvancedDisplay.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER_VERTICAL;
    et.setLayoutParams(params);
    parent.addView(et, pos);
    return "";
}
 
开发者ID:gigabytedevelopers,项目名称:CalcMate,代码行数:16,代码来源:CalculatorEditText.java

示例5: getGravity

private int getGravity(String gravity) {
    switch (gravity) {
        case "CENTER":
            return Gravity.CENTER;
        case "CENTER_VERTICAL":
            return Gravity.CENTER_VERTICAL;
        case "TOP":
            return Gravity.TOP;
        case "LEFT":
            return Gravity.LEFT;
        case "RIGHT":
            return Gravity.RIGHT;
        case "BOTTOM":
            return Gravity.BOTTOM;
        case "START":
            return Gravity.START;
        case "END":
            return Gravity.END;
        default:
            return Gravity.CENTER_VERTICAL;
    }
}
 
开发者ID:cesardeazevedo,项目名称:react-native-collapsing-toolbar,代码行数:22,代码来源:CollapsingToolbarLayoutManager.java

示例6: PRTHeader

public PRTHeader(Context context) {
	super(context);
	int[] size = ResHelper.getScreenSize(context);
	float screenWidth = size[0] < size[1] ? size[0] : size[1];
	float ratio = screenWidth / DESIGN_SCREEN_WIDTH;

	setOrientation(VERTICAL);

	LinearLayout llInner = new LinearLayout(context);
	LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_HORIZONTAL;
	addView(llInner, lp);

	ivArrow = new RotateImageView(context);
	int resId = ResHelper.getBitmapRes(context, "ssdk_oks_ptr_ptr");
	if (resId > 0) {
		ivArrow.setImageResource(resId);
	}
	int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
	lp = new LayoutParams(avatarWidth, avatarWidth);
	lp.gravity = Gravity.CENTER_VERTICAL;
	int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
	lp.topMargin = lp.bottomMargin = avataPadding;
	llInner.addView(ivArrow, lp);

	pbRefreshing = new ProgressBar(context);
	resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_progressbar");
	Drawable pbdrawable = context.getResources().getDrawable(resId);
	pbRefreshing.setIndeterminateDrawable(pbdrawable);
	llInner.addView(pbRefreshing, lp);
	pbRefreshing.setVisibility(View.GONE);

	tvHeader = new TextView(getContext());
	tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
	tvHeader.setTextColor(0xff09bb07);
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(tvHeader, lp);
}
 
开发者ID:ittianyu,项目名称:POCenter,代码行数:40,代码来源:PRTHeader.java

示例7: attributeDell

private void attributeDell(String str)
{
    setHorizontalFadingEdgeEnabled(fadingEdgeEnabled && getTextWidth(str) >= getWidth());
    
    if (gravity == -1)
    {
        gravity = getGravity();
    }
    if (isScrolling)
    {
        if (getTextWidth(str) > getWidth())
        {
            if (!(getGravity() == Gravity.START || getGravity() == (Gravity.TOP | Gravity.START)
                || getGravity() == (Gravity.BOTTOM | Gravity.START)
                || getGravity() == (Gravity.CENTER_VERTICAL | Gravity.START)))
            {
                setSupperGravity(Gravity.START);
            }
        }
        else
        {
            setSupperGravity(gravity);
        }
    }
    else
    {
        if (getTextWidth(str) > getWidth())
        {
            setSupperGravity(Gravity.START);
        }
        else if (getTextWidth(str) <= getWidth())
        {
            setSupperGravity(gravity);
        }
    }
}
 
开发者ID:Dreamxiaoxuan,项目名称:AndroidTvDemo,代码行数:36,代码来源:MarqueeText.java

示例8: PRTHeader

public PRTHeader(Context context) {
	super(context);
	setOrientation(VERTICAL);

	LinearLayout llInner = new LinearLayout(context);
	LinearLayout.LayoutParams lpInner = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpInner.gravity = Gravity.CENTER_HORIZONTAL;
	addView(llInner, lpInner);

	ivArrow = new RotateImageView(context);
	int resId = getBitmapRes(context, "ssdk_oks_ptr_ptr");
	if (resId > 0) {
		ivArrow.setImageResource(resId);
	}
	int dp_32 = dipToPx(context, 32);
	LayoutParams lpIv = new LayoutParams(dp_32, dp_32);
	lpIv.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(ivArrow, lpIv);

	pbRefreshing = new ProgressBar(context);
	llInner.addView(pbRefreshing, lpIv);
	pbRefreshing.setVisibility(View.GONE);

	tvHeader = new TextView(getContext());
	tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvHeader.setGravity(Gravity.CENTER);
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	tvHeader.setPadding(dp_10, dp_10, dp_10, dp_10);
	tvHeader.setTextColor(0xff000000);
	LayoutParams lpTv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(tvHeader, lpTv);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:35,代码来源:FollowList.java

示例9: SnackbarAddView

/**
 * 向Snackbar中添加view
 * @param snackbar
 * @param layoutId
 * @param index 新加布局在Snackbar中的位置
 */
public static void SnackbarAddView( Snackbar snackbar,int layoutId,int index) {
    View snackbarview = snackbar.getView();
    Snackbar.SnackbarLayout snackbarLayout=(Snackbar.SnackbarLayout)snackbarview;

    View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId,null);

    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    p.gravity= Gravity.CENTER_VERTICAL;

    snackbarLayout.addView(add_view,index,p);
}
 
开发者ID:orchidTJJ,项目名称:getword,代码行数:17,代码来源:SnackbarUtil.java

示例10: getFrameLayoutParams

private FrameLayout.LayoutParams getFrameLayoutParams(Boolean left){
    FrameLayout.LayoutParams params =new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    if (left == null){
        params.gravity = Gravity.CENTER;
        return params;
    }
    if (left){
        params.gravity = Gravity.LEFT|Gravity.CENTER_VERTICAL;
    }else {
        params.gravity = Gravity.RIGHT|Gravity.CENTER_VERTICAL;
    }
    return params;
}
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:13,代码来源:ShareGridAdapter.java

示例11: FriendListItem

public FriendListItem(Context context, float ratio) {
	super(context);
	int itemPadding = (int) (ratio * DESIGN_ITEM_PADDING);
	setPadding(itemPadding, 0, itemPadding, 0);
	setMinimumHeight((int) (ratio * DESIGN_ITEM_HEIGHT));
	setBackgroundColor(0xffffffff);

	ivCheck = new ImageView(context);
	LayoutParams lp = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	addView(ivCheck, lp);

	aivIcon = new AsyncImageView(context);
	int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
	lp = new LayoutParams(avatarWidth, avatarWidth);
	lp.gravity = Gravity.CENTER_VERTICAL;
	int avatarMargin = (int) (ratio * DESIGN_AVATAR_PADDING);
	lp.setMargins(avatarMargin, 0, avatarMargin, 0);
	addView(aivIcon, lp);

	tvName = new TextView(context);
	tvName.setTextColor(0xff000000);
	tvName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvName.setSingleLine();
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	lp.weight = 1;
	addView(tvName, lp);

	int resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_check_checked");
	if (resId > 0) {
		bmChd = BitmapFactory.decodeResource(context.getResources(), resId);
	}
	resId = ResHelper.getBitmapRes(getContext(), "ssdk_oks_classic_check_default");
	if (resId > 0) {
		bmUnch = BitmapFactory.decodeResource(context.getResources(), resId);
	}
}
 
开发者ID:android-jian,项目名称:topnews,代码行数:39,代码来源:FriendListItem.java

示例12: alignViews

public void alignViews(String horizontal, String vertical) {
    int h = Gravity.LEFT;
    switch (horizontal) {
        case "left":
            h = Gravity.LEFT;
            break;
        case "center":
            h = Gravity.CENTER_HORIZONTAL;
            break;
        case "right":
            h = Gravity.RIGHT;
            break;
    }

    int v = Gravity.TOP;
    switch (vertical) {
        case "top":
            v = Gravity.TOP;
            break;
        case "center":
            v = Gravity.CENTER_VERTICAL;
            break;
        case "bottom":
            v = Gravity.BOTTOM;
            break;
    }

    setGravity(h | v);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:29,代码来源:PLinearLayout.java

示例13: addView

/**
 * 向Snackbar中添加view
 *
 * @param snackbar
 * @param layoutId
 * @param index    新加布局在Snackbar中的位置
 */
public static void addView(Snackbar snackbar, int layoutId, int index) {
    View snackbarview = snackbar.getView();
    Snackbar.SnackbarLayout snackbarLayout = (Snackbar.SnackbarLayout) snackbarview;

    View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId, null);

    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams
            .WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    p.gravity = Gravity.CENTER_VERTICAL;

    snackbarLayout.addView(add_view, index, p);
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:19,代码来源:SnackbarUtils.java

示例14: initSearchView

private void initSearchView() {
    SearchView searchView = mBinding.svSearch;
    //设置搜索框左边距
    LinearLayout editFrame = (LinearLayout) findViewById(R.id.search_edit_frame);
    LinearLayout.LayoutParams editP = (LayoutParams) editFrame.getLayoutParams();
    editP.leftMargin = 0;
    editP.rightMargin = 0;
    ImageView imageView = (ImageView) findViewById(R.id.search_mag_icon);
    imageView.setAdjustViewBounds(true);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    LinearLayout.LayoutParams lp3 = (LayoutParams) imageView.getLayoutParams();
    lp3.gravity = Gravity.CENTER_VERTICAL;
    lp3.leftMargin = (int) (DensityUtil.dip2px(8f) * DensityUtil.getBaseScale(getContext()));
    lp3.rightMargin = (int) (DensityUtil.dip2px(-2f) * DensityUtil.getBaseScale(getContext()));

    View view = searchView.findViewById(R.id.search_plate);
    view.setBackgroundColor(getResources().getColor(R.color.colorTransparent));
    EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
    editText.setBackgroundColor(Color.TRANSPARENT);
    editText.setTextSize(11.5f);
    editText.setTextColor(getResources().getColor(R.color.colorText));
    editText.setHintTextColor(getResources().getColor(R.color.colorHint));
    try {
        Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
        fCursorDrawableRes.setAccessible(true);
        int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
        Field fEditor = TextView.class.getDeclaredField("mEditor");
        fEditor.setAccessible(true);
        Object editor = fEditor.get(editText);
        Class<?> clazz = editor.getClass();
        Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
        fCursorDrawable.setAccessible(true);
        if (mCursorDrawableRes <= 0) return;
        Drawable cursorDrawable = ContextCompat.getDrawable(searchView.getContext(), mCursorDrawableRes);
        if (cursorDrawable == null) return;
        Drawable tintDrawable = DrawableCompat.wrap(cursorDrawable);
        DrawableCompat.setTintList(tintDrawable, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.bg_search)));
        Drawable[] drawables = new Drawable[]{tintDrawable, tintDrawable};
        fCursorDrawable.set(editor, drawables);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:xieyangxuejun,项目名称:SearchLayout,代码行数:43,代码来源:FlexSearchLayout.java

示例15: createView

private View createView(final Context context, RemoteViews remoteViews, boolean isBig, boolean systemId) {
	if (remoteViews == null)
		return null;
	Context base = mNotificationCompat.getHostContext();
	init(base);
	VLog.v(TAG, "createView:big=" + isBig + ",system=" + systemId);
	// TODO 需要适配
	int height = isBig ? notification_max_height : notification_min_height;

	int width = mWidthCompat.getNotificationWidth(base, notification_panel_width, height,
			notification_side_padding);
	VLog.v(TAG, "createView:getNotificationWidth=" + width);
	ViewGroup frameLayout = new FrameLayout(context);
	VLog.v(TAG, "createView:apply");

	View view1 = apply(context, remoteViews);

	FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
			ViewGroup.LayoutParams.MATCH_PARENT);
	params.gravity = Gravity.CENTER_VERTICAL;
	frameLayout.addView(view1, params);
	if (view1 instanceof ViewGroup) {
		VLog.v(TAG, "createView:fixTextView");
		fixTextView((ViewGroup) view1);
	}
	int mode;
	// TODO 各种适配
	if (systemId) {
		mode = View.MeasureSpec.EXACTLY;
	} else {
		if (isBig) {
			mode = View.MeasureSpec.AT_MOST;
		} else {
			mode = View.MeasureSpec.EXACTLY;
		}
	}
	VLog.v(TAG, "createView:layout");
	View mCache = frameLayout;
	mCache.layout(0, 0, width, height);
	mCache.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
			View.MeasureSpec.makeMeasureSpec(height, mode));
	mCache.layout(0, 0, width, mCache.getMeasuredHeight());
	VLog.v(TAG, "notification:systemId=" + systemId + ",max=%d/%d, szie=%d/%d", width, height,
			mCache.getMeasuredWidth(), mCache.getMeasuredHeight());
	return mCache;
}
 
开发者ID:codehz,项目名称:container,代码行数:46,代码来源:RemoteViewsFixer.java


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