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


Java Gravity.CENTER属性代码示例

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


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

示例1: RunwiseDialog

@Inject
public RunwiseDialog(@ActivityContext Context context) {
	super(context, R.style.CustomProgressDialog);
	setContentView(R.layout.dialog_layout);
	Window window = getWindow();
	window.getAttributes().gravity = Gravity.CENTER;
		window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	this.setCancelable(true);
	this.setCanceledOnTouchOutside(false);
	this.context = (TextView) this.findViewById(R.id.context);
       cancle = (Button) this.findViewById(R.id.cancle);
	okBtn = (Button) this.findViewById(R.id.ok);
	vLine = this.findViewById(R.id.vline);
	hLine = this.findViewById(R.id.hline);
	title = (TextView) this.findViewById(R.id.title);
	btnLayout = (LinearLayout) this.findViewById(R.id.dialog_btn_layout);
	setLeftBtnListener("取消",null);
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:18,代码来源:RunwiseDialog.java

示例2: onVideoItemChangeToFullScreenClick

@Override
public void onVideoItemChangeToFullScreenClick(EssayAdapter.VideoViewHolder videoViewHolder) {
    // 这里这个ViewGroup 是Window的
    final ViewGroup vp = (ViewGroup)(findViewById(Window.ID_ANDROID_CONTENT));

    videoViewHolder.basicVideoView.setPlayer(null);

    final BasicVideoView newBasicVideoView = (BasicVideoView) View.inflate(this, R.layout.basic_videoview, null);
    newBasicVideoView.setPlayer(mPlayer);
    View changeToInsetScreen = newBasicVideoView.findViewById(R.id.changeToInsetScreen);
    changeToInsetScreen.setOnClickListener(this);

    final FrameLayout.LayoutParams lpParent = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    final FrameLayout frameLayout = new FrameLayout(this);
    frameLayout.setId(R.id.full_screen_id);

    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    lp.gravity = Gravity.CENTER;
    frameLayout.addView(newBasicVideoView, lp);
    vp.addView(frameLayout, lpParent);
    mPlayer.seekTo(mPlayer.getCurrentPosition() - 20);
}
 
开发者ID:xinpianchang,项目名称:NSMPlayer-Android,代码行数:22,代码来源:EssayDetailActivity.java

示例3: SwipeDecor

public SwipeDecor() {
    mViewWidth = 0;
    mViewHeight = 0;
    mPaddingTop = 0;
    mPaddingLeft = 0;
    mMarginTop = 0;
    mMarginLeft = 0;
    mRelativeScale = 0.05f;
    mAnimateScale = true;
    mSwipeInMsgLayoutId = PRIMITIVE_NULL;
    mSwipeOutMsgLayoutId = PRIMITIVE_NULL;
    mViewGravity = Gravity.CENTER ;
    mSwipeInMsgGravity = Gravity.CENTER ;
    mSwipeOutMsgGravity = Gravity.CENTER ;
    mSwipeDistToDisplayMsg = 30;
    mSwipeAnimTime = 200;
    mSwipeAnimFactor = 0.75f;
    mSwipeRotationAngle = 15;
}
 
开发者ID:sinhaDroid,项目名称:BlogBookApp,代码行数:19,代码来源:SwipeDecor.java

示例4: managerAppInit

public void managerAppInit()
	{
		View v = LayoutInflater.from(mContext).inflate(R.layout.item_pager_layout, null);
		LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		params.gravity = Gravity.CENTER;
        int itemCount = -1;
		if(mPagerIndex < mPagerCount - 1)
		{
			itemCount = 15;
		}else
		{
			itemCount = (mAppList.size() - (mPagerCount-1)*15);
		}
		for(int i = 0; i < itemCount; i++)
		{
			appIcons[i] = (ImageView) v.findViewById(iconIds[i]);
			appNames[i] = (TextView)v.findViewById(nameIds[i]);
			appIcons[i].setImageDrawable(mAppList.get(mPagerIndex*15 + i).getIcon());
            appItems[i] = (LinearLayout)v.findViewById(itemIds[i]);
            appNames[i].setText(mAppList.get(mPagerIndex * 15 + i).getName());
            appItems[i].setVisibility(View.VISIBLE);
            appItems[i].setOnClickListener(this);
//            appItems[i].setOnFocusChangeListener(focusChangeListener);
        }
		addView(v);
	}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:26,代码来源:AllApp.java

示例5: CustomDialog

public CustomDialog(Context context, int width, int height) {
    super(context, R.style.DialogTheme);
    // 设置内容
    setContentView(R.layout.dialog_layout);
    setCanceledOnTouchOutside(true);//设置点击dialog外面都可以取消dialog
    setCancelable(true);//设置点击返回键都能取消
    // 设置窗口属性
    Window window = getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    // 设置宽度、高度、密度、对齐方式
    float density = getDensity(context);
    params.width = (int) (width * density);
    params.height = (int) (height * density);
    params.gravity = Gravity.CENTER;
    window.setAttributes(params);
}
 
开发者ID:wangzhaosheng,项目名称:publicProject,代码行数:16,代码来源:CustomDialog.java

示例6: onException

@Override
public void onException(NestedContainer container, String errCode, String msg) {
  if (TextUtils.equals(errCode, WXRenderErrorCode.WX_NETWORK_ERROR) && container instanceof WXEmbed) {
    final WXEmbed comp = ((WXEmbed)container);
    final ImageView imageView = new ImageView(comp.getContext());
    imageView.setImageResource(R.drawable.error);
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ERROR_IMG_WIDTH, ERROR_IMG_HEIGHT);
    layoutParams.gravity = Gravity.CENTER;
    imageView.setLayoutParams(layoutParams);
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setAdjustViewBounds(true);
    imageView.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        imageView.setOnClickListener(null);
        imageView.setEnabled(false);
        comp.loadInstance();
      }
    });
    FrameLayout hostView = comp.getHostView();
    hostView.removeAllViews();
    hostView.addView(imageView);
    WXLogUtils.e("WXEmbed", "NetWork failure :" + errCode + ",\n error message :" + msg);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:25,代码来源:WXEmbed.java

示例7: addTag

private void addTag(){
    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT
            , ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
    int l = dp2px(8);
    int t = dp2px(8);
    int r = dp2px(8);
    int b = dp2px(8);
    layoutParams.setMargins(l, t, r, b);
    //addView会引起所有View的layout
    addView(mTextView, layoutParams);
}
 
开发者ID:chengkun123,项目名称:ReadMark,代码行数:11,代码来源:TagView.java

示例8: show

/**
	 * 弹出自定义ProgressDialog
	 * 
	 * @param context
	 *            上下文
	 * @param message
	 *            提示
	 * @param cancelable
	 *            是否按返回键取消
	 * @param cancelListener
	 *            按下返回键监听
	 * @return
	 */
	public static CustomLoadDialog show(Context context, CharSequence message, boolean cancelable, OnCancelListener cancelListener,int resId) {
		dialog = new CustomLoadDialog(context, R.style.Custom_Progress);
		dialog.setTitle("");
//		dialog.setContentView(R.layout.progress_custom);
		dialog.setContentView(resId);
		if (message == null || message.length() == 0) {
			dialog.findViewById(R.id.message).setVisibility(View.GONE);
		} else {
			TextView txt = (TextView) dialog.findViewById(R.id.message);
			txt.setText(message);
		}
		// 按返回键是否取消
		dialog.setCancelable(cancelable);
		// 监听返回键处理
		dialog.setOnCancelListener(cancelListener);
		// 设置居中
		dialog.getWindow().getAttributes().gravity = Gravity.CENTER;
		WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
		// 设置背景层透明度
		lp.dimAmount = 0.2f;
		dialog.getWindow().setAttributes(lp);
		// dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

		if(!((Activity) context).isFinishing())
		{
			//show dialog
			dialog.show();
		}
		return dialog;
	}
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:43,代码来源:CustomLoadDialog.java

示例9: initGestureView

/**
 * 初始化手势操作时显示的 View
 */
private void initGestureView() {
    mGestureView = new AbsGestureView(getContext());

    LayoutParams params = new LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.CENTER);

    View gestureRootView = mGestureView.getRootView();

    gestureRootView.setLayoutParams(params);

    this.addView(gestureRootView);
}
 
开发者ID:SethWen,项目名称:GestureVideoView,代码行数:17,代码来源:GestureVideoView.java

示例10: onBindViewHolder

@Override public void onBindViewHolder(ViewHolder holder, int position) {
  Snap snap = mSnaps.get(position);
  holder.snapTextView.setText(snap.getText());

  if (snap.getGravity() == Gravity.START || snap.getGravity() == Gravity.END) {
    holder.recyclerView.setLayoutManager(
        new LinearLayoutManager(holder.recyclerView.getContext(), LinearLayoutManager.HORIZONTAL,
            false));
    holder.recyclerView.setOnFlingListener(null);
    new GravitySnapHelper(snap.getGravity()).attachToRecyclerView(holder.recyclerView);
  } else if (snap.getGravity() == Gravity.CENTER_HORIZONTAL
      || snap.getGravity() == Gravity.CENTER_VERTICAL
      || snap.getGravity() == Gravity.CENTER) {
    holder.recyclerView.setLayoutManager(new LinearLayoutManager(holder.recyclerView.getContext(),
        snap.getGravity() == Gravity.CENTER_HORIZONTAL ? LinearLayoutManager.HORIZONTAL
            : LinearLayoutManager.VERTICAL, false));
    holder.recyclerView.setOnFlingListener(null);
    new LinearSnapHelper().attachToRecyclerView(holder.recyclerView);
  } else { // Top / Bottom
    holder.recyclerView.setLayoutManager(
        new LinearLayoutManager(holder.recyclerView.getContext()));
    holder.recyclerView.setOnFlingListener(null);
    new GravitySnapHelper(snap.getGravity()).attachToRecyclerView(holder.recyclerView);
  }

  holder.recyclerView.setAdapter(new Adapter(snap.getGravity() == Gravity.START
      || snap.getGravity() == Gravity.END
      || snap.getGravity() == Gravity.CENTER_HORIZONTAL, snap.getApps()));
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:29,代码来源:SnapAdapter.java

示例11: initComponentHostView

@Override
protected FrameLayout initComponentHostView(Context context) {
    FrameLayout view = new FrameLayout(context);

    // init view pager
    FrameLayout.LayoutParams pagerParams = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    pagerParams.gravity = Gravity.CENTER;
    mViewPager = new WXCircleViewPager(mContext);
    mViewPager.setLayoutParams(pagerParams);

    // init adapter
    mAdapter = new WXCirclePageAdapter();
    mViewPager.setAdapter(mAdapter);

    // add to parent
    view.addView(mViewPager);
    mViewPager.addOnPageChangeListener(mPageChangeListener);

    // set animation
    mViewPager.setPageTransformer(true, new ZoomTransformer());
    mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
    view.setClipChildren(false);
    registerActivityStateListener();

    return view;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:27,代码来源:WXSliderNeighbor.java

示例12: getVideoLoadingProgressView

@Override
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.

        // create the linear layout
        LinearLayout layout = new LinearLayout(parentEngine.getView().getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(parentEngine.getView().getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);

        mVideoProgressView = layout;
    }
return mVideoProgressView;
}
 
开发者ID:fachrihawari,项目名称:cordova-vuetify,代码行数:28,代码来源:SystemWebChromeClient.java

示例13: getVideoLoadingProgressView

@Override
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {            
        // Create a new Loading view programmatically.
        
        // create the linear layout
        LinearLayout layout = new LinearLayout(this.appView.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(this.appView.getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);   
        layout.addView(bar);
        
        mVideoProgressView = layout;
    }
return mVideoProgressView; 
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:28,代码来源:CordovaChromeClient.java

示例14: onPreExecute

@Override
protected void onPreExecute() {
	try {//sometime it crash if the user refresh while the list is already being refreshed
		super.onPreExecute();

		// Replace the ListView with a ProgressBar
		mProgBar = new ProgressBar(volumeBrowserActivity, null,android.R.attr.progressBarStyleLarge);

		// Set the layout to fill the screen
		mListView = volumeBrowserActivity.getListView();
		mLayout = (LinearLayout) mListView.getParent();
		if (mLayout==null) return;
		mLayout.setGravity(Gravity.CENTER);
		mLayout.setLayoutParams(new FrameLayout.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

		// Set the ProgressBar in the center of the layout
		LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		layoutParams.gravity = Gravity.CENTER;
		mProgBar.setLayoutParams(layoutParams);

		// Replace the ListView with the ProgressBar
		mLayout.removeView(mListView);
		mLayout.addView(mProgBar);
		mProgBar.setVisibility(View.VISIBLE);
	} catch (Exception e){
		e.printStackTrace();
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:30,代码来源:FillTask.java

示例15: getAddView

private View getAddView() {

		mAddImageView=new ImageView(this.getContext());
		LayoutParams param=getLayoutParams((getMeasuredWidth()-20)/4,getMeasuredHeight());
		param.weight=1;
		param.gravity= Gravity.CENTER;
		mAddImageView.setLayoutParams(param);
		mDeleteImageView.setScaleType(ImageView.ScaleType.CENTER);

		setBackgroundDrawable(mAddImageView, addDrawable);
		return mAddImageView;
	}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:12,代码来源:DishesView.java


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