LinearLayout setGravity - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for LinearLayout setGravity method.

This code example shows how to use the following methods:setId, setLayoutParams, setVisibility, addView, setGravity
8
CodeRank
This code example shows how to use the following methods:setBackgroundResource, setLayoutParams, addView, setGravity, setOrientation
This code example shows how to use the following methods:setBackgroundColor, addView, setContentView, setGravity
  protected AndroidPlatform platform() { 
    return platform;
  } 
 
  protected void setContentView(GameViewGL view) {
    LinearLayout layout = new LinearLayout(this);
    layout.setBackgroundColor(0xFF000000);
    layout.setGravity(Gravity.CENTER);
    layout.addView(gameView);
    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    getWindow().setContentView(layout, params);
  } 
} 
8
CodeRank
This code example shows how to use the following methods:getContext, setBackgroundDrawable, setPadding, setGravity
	 
	public static void setHeaderProfile(LinearLayout llProfileHeader) {
		if (llProfileHeader == null) {
			return; 
		} 
		Theme theme = ThemeUtil.createTheme(llProfileHeader.getContext());
		llProfileHeader.setBackgroundDrawable(theme.getDrawable("selector_bg_profile_header"));
		int padding8 = theme.dip2px(8);
		llProfileHeader.setPadding(padding8, padding8, padding8, padding8);
		llProfileHeader.setGravity(Gravity.CENTER);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:setBackgroundDrawable, setLayoutParams, addView, setGravity
			 
			LinearLayout.LayoutParams master = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
			 
			layout.setLayoutParams(master);
			 
			LinearLayout toolbar = new LinearLayout(context);
			 
			LinearLayout.LayoutParams toolbarParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, displayUtils.getDIP(44));
			 
			toolbar.setLayoutParams(toolbarParams);
			toolbar.setGravity(Gravity.CENTER_VERTICAL|Gravity.RIGHT);
			toolbar.setBackgroundDrawable(viewBg);
			 
			SocializeButton button = buttonFactory.getBean();
			button.setOnClickListener(new OnClickListener() {
				@Override 
				public void onClick(View v) {
					dialog.dismiss();
				} 
			}); 

8
CodeRank
This code example shows how to use the following methods:setPadding, addView, setGravity, setOrientation
		public Object getItem(int position) {
			return makeMenuItem(position);
		} 
		 
		private LinearLayout makeMenuItem(int position) {
			LinearLayout lLayout = new LinearLayout(this.mContext);
			lLayout.setOrientation(LinearLayout.VERTICAL);
			lLayout.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
			lLayout.setPadding(10, 10, 10, 10);
			 
			TextView lView = new TextView(this.mContext);
			lView.setText(mTexts[position]);
			lView.setTextSize(mFontSize);
			lView.setTextColor(mFontColor);
			lView.setGravity(Gravity.CENTER);
			lView.setPadding(5, 5, 5, 5);
			 
			ImageView lImageView = new ImageView(this.mContext);
			lImageView.setBackgroundResource(this.mResId[position]);
			 

7
CodeRank
This code example shows how to use the following methods:setId, setVisibility, addView, setGravity, setOrientation
 
        FrameLayout root = new FrameLayout(context);
 
        // ------------------------------------------------------------------ 
 
        LinearLayout pframe = new LinearLayout(context);
        pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
        pframe.setOrientation(LinearLayout.VERTICAL);
        pframe.setVisibility(View.GONE);
        pframe.setGravity(Gravity.CENTER);
 
        ProgressBar progress = new ProgressBar(context, null,
                android.R.attr.progressBarStyleLarge);
        pframe.addView(progress, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
 
        root.addView(pframe, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
 
        // ------------------------------------------------------------------ 
7
CodeRank
This code example shows how to use the following methods:setBackgroundColor, setPadding, addView, setGravity
7
CodeRank
This code example shows how to use the following methods:setId, setLayoutParams, setPadding, setGravity, setOrientation
This code example shows how to use the following methods:setGravity
    } 
 
    @Test 
    public void canAnswerGravity() throws Exception { 
        assertThat(shadowOf(linearLayout).getGravity()).isEqualTo(Gravity.TOP | Gravity.START);
        linearLayout.setGravity(Gravity.CENTER_VERTICAL);
        assertThat(shadowOf(linearLayout).getGravity()).isEqualTo(Gravity.CENTER_VERTICAL);
    } 
} 
7
CodeRank

Related LinearLayout setGravity Questions & Answers:

setGravity Method Overview
Describes how the child views are positioned.
See Code Examples for other Android LinearLayout Methods: