當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。