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


Java RelativeLayout.setGravity方法代码示例

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


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

示例1: addTab

import android.widget.RelativeLayout; //导入方法依赖的package包/类
protected void addTab(int index, CharSequence text, int iconResId) {
    TabView tabView = new TabView(this, getContext(), text);
    tabView.setIndex(index);
    tabView.setFocusable(true);
    tabView.setOnClickListener(this.mTabClickListener);
    if (iconResId != 0) {
        tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
    }
    int width = this.mMeanWidth == -1 ? getTabWidth(text) : this.mMeanWidth;
    if (this.mMeanWidth != -1) {
        tabView.setSize(this.mMeanWidth, UIsUtils.dipToPx(38.0f));
    } else {
        tabView.setSize(width, UIsUtils.dipToPx(38.0f));
    }
    RelativeLayout relativeLayout = new RelativeLayout(this.mContext);
    relativeLayout.setGravity(17);
    relativeLayout.setLayoutParams(new LayoutParams(-2, UIsUtils.dipToPx(38.0f)));
    LayoutParams params = new LayoutParams(-2, UIsUtils.dipToPx(38.0f));
    params.setMargins(TAB_MARGIN, 0, TAB_MARGIN, 0);
    tabView.setLayoutParams(params);
    relativeLayout.addView(tabView);
    if (this.mIsHome) {
        ThemeDataManager.getInstance(this.mContext).setContentTheme(tabView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR);
    }
    ImageView imageView = new ImageView(this.mContext);
    LayoutParams imageViewParams = new LayoutParams(width, UIsUtils.dipToPx(2.0f));
    imageViewParams.setMargins(TAB_MARGIN, UIsUtils.dipToPx(36.0f), TAB_MARGIN, 0);
    imageView.setLayoutParams(imageViewParams);
    relativeLayout.addView(imageView);
    imageView.setBackgroundDrawable(getResources().getDrawable(2130838177));
    if (this.mIsHome) {
        ThemeDataManager.getInstance(this.mContext).setShapeSelectorViewTheme(imageView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR, 2, true);
    }
    this.mTabLayout.addView(relativeLayout);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:36,代码来源:ChannelTabPageIndicator.java

示例2: ViewHolder

import android.widget.RelativeLayout; //导入方法依赖的package包/类
public ViewHolder(View itemView) {
    super(itemView);
    frontText = (AutoResizeTextView) itemView.findViewById(R.id.textFront);
    frontText.setOnClickListener(this);
    backText = (AutoResizeTextView) itemView.findViewById(R.id.textBack);
    backText.setOnClickListener(this);
    delete = (ImageView) itemView.findViewById(R.id.delete);
    delete.setOnClickListener(this);
    flip = (ImageView) itemView.findViewById(R.id.flip);
    flip.setOnClickListener(this);
    flipBack = (ImageView) itemView.findViewById(R.id.flipBack);
    flipBack.setOnClickListener(this);
    front = (RelativeLayout) itemView.findViewById(R.id.front);
    back = (RelativeLayout) itemView.findViewById(R.id.back);
    back.setGravity(View.GONE);
    bg = (ImageView) itemView.findViewById(R.id.card);
    bgBack = (ImageView) itemView.findViewById(R.id.cardBack);
    editCard = (ImageView) itemView.findViewById(R.id.editCard);
    editCard.setOnClickListener(this);
    editCardBack = (ImageView) itemView.findViewById(R.id.editCardBack);
    editCardBack.setOnClickListener(this);
}
 
开发者ID:AbduazizKayumov,项目名称:Flashcard-Maker-Android,代码行数:23,代码来源:RVCardsAdapter.java

示例3: init

import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    mListView = new InternalListView(getContext(), attrs);
    LayoutParams listParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    listParams.addRule(ALIGN_PARENT_TOP);
    mListView.setLayoutParams(listParams);
    mListView.setOnScrollListener(new HeaderListViewOnScrollListener());
    mListView.setVerticalScrollBarEnabled(true);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mAdapter != null) {
                mAdapter.onItemClick(parent, view, position, id);
            }
        }
    });
    addView(mListView);

    mHeader = new RelativeLayout(getContext());
    LayoutParams headerParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    headerParams.addRule(ALIGN_PARENT_TOP);
    mHeader.setLayoutParams(headerParams);
    mHeader.setGravity(Gravity.BOTTOM);
    addView(mHeader);
}
 
开发者ID:smuyyh,项目名称:StickyHeaderListView,代码行数:25,代码来源:StickyHeaderListView.java

示例4: DProgressBar

import android.widget.RelativeLayout; //导入方法依赖的package包/类
public static ProgressBar DProgressBar(Context context) {

        ViewGroup layout = (ViewGroup) ((Activity) context).findViewById(android.R.id.content).getRootView();
        ProgressBar mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
        mProgressBar.setIndeterminate(true);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        RelativeLayout rl = new RelativeLayout(context);
        rl.setGravity(Gravity.CENTER);
        rl.addView(mProgressBar);
        layout.addView(rl, params);
        return mProgressBar;
    }
 
开发者ID:derohimat,项目名称:SgPSI,代码行数:13,代码来源:DialogFactory.java

示例5: setupLayout

import android.widget.RelativeLayout; //导入方法依赖的package包/类
public final void setupLayout() {
    this.mPreview = new CameraPreview(getContext());
    RelativeLayout relativeLayout = new RelativeLayout(getContext());
    relativeLayout.setGravity(17);
    relativeLayout.setBackgroundColor(-16777216);
    relativeLayout.addView(this.mPreview);
    addView(relativeLayout);
    this.mViewFinderView = createViewFinderView(getContext());
    if (this.mViewFinderView instanceof View) {
        addView((View) this.mViewFinderView);
        return;
    }
    throw new IllegalArgumentException("IViewFinder object returned by 'createViewFinderView()' should be instance of android.view.View");
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:BarcodeScannerView.java

示例6: initLayout

import android.widget.RelativeLayout; //导入方法依赖的package包/类
public RelativeLayout initLayout() {
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    // set the parent
    parentScriptedLayout = new RelativeLayout(this);
    parentScriptedLayout.setLayoutParams(layoutParams);
    parentScriptedLayout.setGravity(Gravity.BOTTOM);
    parentScriptedLayout.setBackgroundColor(getResources().getColor(R.color.transparent));

    return parentScriptedLayout;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:12,代码来源:AppRunnerService.java

示例7: create

import android.widget.RelativeLayout; //导入方法依赖的package包/类
public static RelativeLayout create(Context context) {
	SizeHelper.prepare(context);

	RelativeLayout root = new RelativeLayout(context);
	root.setId(ResHelper.getIdRes(context, "rl_lv_item_bg"));
	AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
			SizeHelper.fromPxWidth(95));
	root.setLayoutParams(params);
	int padding = SizeHelper.fromPxWidth(14);
	root.setPadding(padding, padding, padding, padding);
	root.setGravity(Gravity.CENTER_VERTICAL);
	root.setBackgroundColor(0xffffffff);

	AsyncImageView contactImage = new AsyncImageView(context);
	contactImage.setId(ResHelper.getIdRes(context, "iv_contact"));
	RelativeLayout.LayoutParams contactImageParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(64),
			SizeHelper.fromPxWidth(64));
	contactImageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	contactImage.setLayoutParams(contactImageParams);
	contactImage.setScaleType(ScaleType.FIT_CENTER);
	root.addView(contactImage);

	LinearLayout wrapper = new LinearLayout(context);
	RelativeLayout.LayoutParams wrapperParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
			RelativeLayout.LayoutParams.WRAP_CONTENT);
	wrapperParams.addRule(RelativeLayout.RIGHT_OF, ResHelper.getIdRes(context, "iv_contact"));
	wrapperParams.addRule(RelativeLayout.CENTER_VERTICAL);
	wrapperParams.leftMargin = SizeHelper.fromPxWidth(12);
	wrapper.setLayoutParams(wrapperParams);
	wrapper.setOrientation(LinearLayout.VERTICAL);
	root.addView(wrapper);

	TextView name = new TextView(context);
	name.setId(ResHelper.getIdRes(context, "tv_name"));
	LinearLayout.LayoutParams nameParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	name.setLayoutParams(nameParams);
	name.setTextColor(0xff333333);
	name.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(28));
	wrapper.addView(name);

	TextView contact = new TextView(context);
	contact.setId(ResHelper.getIdRes(context, "tv_contact"));
	LinearLayout.LayoutParams contactParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	contact.setLayoutParams(contactParams);
	contact.setTextColor(0xff999999);
	contact.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	wrapper.addView(contact);

	Button add = new Button(context);
	add.setId(ResHelper.getIdRes(context, "btn_add"));
	RelativeLayout.LayoutParams addParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(92),
			SizeHelper.fromPxWidth(46));
	addParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	addParams.addRule(RelativeLayout.CENTER_VERTICAL);
	add.setLayoutParams(addParams);
	int resid = ResHelper.getStringRes(context, "smssdk_add_contact");
	add.setText(resid);
	add.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(22));
	add.setTextColor(0xff797979);
	//resid = R.getBitmapRes(context, "smssdk_corners_bg");
	add.setBackgroundDrawable(DrawableHelper.createCornerBg(context));
	add.setPadding(0, 0, 0, 0);
	root.addView(add);

	return root;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:69,代码来源:ContactsListviewItemLayout.java

示例8: ProgressBarHandler

import android.widget.RelativeLayout; //导入方法依赖的package包/类
public ProgressBarHandler(Context context) {

        ViewGroup layout = (ViewGroup) ((Activity) context).findViewById(android.R.id.content).getRootView();

        mProgressBar = new ProgressBar(context, null);
        mProgressBar.setIndeterminate(true);

        mProgressBar.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(context, R.color.colorPrimary),
                android.graphics.PorterDuff.Mode.MULTIPLY);

        RelativeLayout.LayoutParams params = new
                RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);

        RelativeLayout rl = new RelativeLayout(context);

        rl.setGravity(Gravity.CENTER);
        rl.addView(mProgressBar);

        layout.addView(rl, params);

        hideProgress();
    }
 
开发者ID:SoftprodigyIndia,项目名称:AndroidAppBoilerplate,代码行数:23,代码来源:ProgressBarHandler.java

示例9: BaseMessageDialog

import android.widget.RelativeLayout; //导入方法依赖的package包/类
protected BaseMessageDialog(Activity activity, boolean fullscreen, BaseMessageOptions options,
    WebInterstitialOptions webOptions, HTMLOptions htmlOptions) {
  super(activity, getTheme(activity));

  SizeUtil.init(activity);
  this.activity = activity;
  this.options = options;
  this.webOptions = webOptions;
  this.htmlOptions = htmlOptions;
  if (webOptions != null) {
    isWeb = true;
  }
  if (htmlOptions != null) {
    isHtml = true;
  }
  dialogView = new RelativeLayout(activity);
  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  dialogView.setBackgroundColor(Color.TRANSPARENT);
  dialogView.setLayoutParams(layoutParams);

  RelativeLayout view = createContainerView(activity, fullscreen);
  view.setId(108);
  dialogView.addView(view, view.getLayoutParams());

  if ((!isWeb || (webOptions != null && webOptions.hasDismissButton())) && !isHtml) {
    CloseButton closeButton = createCloseButton(activity, fullscreen, view);
    dialogView.addView(closeButton, closeButton.getLayoutParams());
  }

  setContentView(dialogView, dialogView.getLayoutParams());

  dialogView.setAnimation(createFadeInAnimation());

  if (!fullscreen) {
    Window window = getWindow();
    if (window == null) {
      return;
    }
    if (!isHtml) {
      window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
      if (Build.VERSION.SDK_INT >= 14) {
        window.setDimAmount(0.7f);
      }
    } else {
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
      window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
          WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
      if (htmlOptions != null &&
          MessageTemplates.Args.HTML_ALIGN_BOTTOM.equals(htmlOptions.getHtmlAlign())) {
        dialogView.setGravity(Gravity.BOTTOM);
      }
    }
  }
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:56,代码来源:BaseMessageDialog.java

示例10: setAdapter

import android.widget.RelativeLayout; //导入方法依赖的package包/类
@Override
public void setAdapter(Adapter adapter) {
    ArrayList<View> headers = new ArrayList<>();
    ArrayList<View> footers = new ArrayList<>();

    View refreshView = LayoutInflater.from(getContext()).inflate(R.layout.my_refresh, null);
    headerView = refreshView;

    RelativeLayout headerLayout = new RelativeLayout(getContext());
    headerLayout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    headerLayout.addView(headerView, RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    headerLayout.setGravity(Gravity.BOTTOM);

    status = (TextView) refreshView.findViewById(R.id.status);
    headerView.post(new Runnable() {
        @Override
        public void run() {
            headerViewHeight = headerView.getHeight();
            RelativeLayout.LayoutParams l = (RelativeLayout.LayoutParams) headerView.getLayoutParams();
            l.setMargins(0, -headerViewHeight, 0, 0);
            headerView.requestLayout();
        }
    });
    headers.add(headerLayout);

    LinearLayout footerLayout = new LinearLayout(getContext());
    footerLayout.setGravity(Gravity.CENTER);
    footerLayout.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    footers.add(footerLayout);
    footerLayout.setPadding(0,15,0,15);
    footerLayout.addView(new ProgressBar(getContext(), null, android.R.attr.progressBarStyleSmall));

    TextView text = new TextView(getContext());
    text.setText("正在加载...");
    footerLayout.addView(text);
    footerView=footerLayout;
    footerView.setVisibility(GONE);

    myWrapAdapter = new MyWrapAdapter(adapter, headers, footers);
    super.setAdapter(myWrapAdapter);
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:43,代码来源:MyRecyclerView.java

示例11: init

import android.widget.RelativeLayout; //导入方法依赖的package包/类
/**
 * 初始化,包括必要的 {@link #paint} 等变量初始化,xml属性获取等.
 *
 * @param attrs {@link AttributeSet}
 */
private void init(AttributeSet attrs)
{
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Paint.Align.CENTER);

    toast = new Toast(context);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);

    toastView = new RelativeLayout(context);
    toastView.setGravity(Gravity.CENTER);
    toast.setView(toastView);

    toastTextView = new TextView(context);
    toastTextView.setGravity(Gravity.CENTER);
    toastView.addView(toastTextView);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.QuickIndexView);
    textColor = typedArray.getColor(R.styleable.QuickIndexView_textColor, Colors.BLACK);
    quickTextColor = typedArray.getColor(R.styleable.QuickIndexView_quickTextColor, Colors.BLACK);
    topDrawable = typedArray.getDrawable(R.styleable.QuickIndexView_topDrawable);
    bottomDrawable = typedArray.getDrawable(R.styleable.QuickIndexView_bottomDrawable);

    showToast = typedArray.getBoolean(R.styleable.QuickIndexView_showToast, true);
    quickBackground = typedArray.getDrawable(R.styleable.QuickIndexView_quickBackground);
    quickWidth = typedArray.getDimensionPixelSize(R.styleable.QuickIndexView_quickWidth,
            DensityTool.dp2px(context, DEFAULT_WIDTH_DP));
    quickHeight = typedArray.getDimensionPixelSize(R.styleable.QuickIndexView_quickHeight,
            DensityTool.dp2px(context, DEFAULT_WIDTH_DP));

    changeToastViewSize();

    CharSequence[] textArray = typedArray.getTextArray(R.styleable.QuickIndexView_quickLetters);
    if(textArray != null)
    {
        letterList = new ArrayList<>();
        for(CharSequence charSequence : textArray)
        {
            letterList.add(charSequence.toString());
        }
    }
    else
    {
        setLetterArray(ResCompat.getStringArray(context, R.array.defaultQuickIndexViewLetters));
    }

    typedArray.recycle();

    bitmapRect = new Rect();
    outRect = new Rect();
}
 
开发者ID:Ayvytr,项目名称:EasyAndroid,代码行数:58,代码来源:QuickIndexView.java


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