List of usage examples for android.widget LinearLayout setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:Main.java
private static LinearLayout createLLforAddToCalendar(final Context context, final CheckBox checkBox) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(checkBox);//from ww w . j ava 2 s .c om return linearLayout; }
From source file:Main.java
public static void setLinearLayoutParams(LinearLayout linear, Activity actvity) { LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, getScreenHeight(actvity) - 200); linear.setLayoutParams(lp); }
From source file:com.kaedea.frontia.demo.DemoListFragment.java
@SuppressWarnings("ResourceType") public static View getItemViewLayout(Context context) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); int[] attrs = new int[] { R.attr.selectableItemBackground }; TypedArray typedArray = context.obtainStyledAttributes(attrs); int backgroundResource = typedArray.getResourceId(0, 0); linearLayout.setBackgroundResource(backgroundResource); typedArray.recycle();/*from ww w . ja va 2 s . c o m*/ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); linearLayout.setLayoutParams(layoutParams); // Title TextView tvTitle = new TextView(context); tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16f); tvTitle.setMaxLines(1); tvTitle.setTextColor(Color.parseColor("#212121")); tvTitle.setId(ID_TITLE); layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(Utils.dpToPx(context, 20f), Utils.dpToPx(context, 10f), Utils.dpToPx(context, 20f), 0); linearLayout.addView(tvTitle, layoutParams); // Sub Title TextView tvSubTitle = new TextView(context); tvSubTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14f); tvSubTitle.setMaxLines(2); tvSubTitle.setTextColor(Color.parseColor("#757575")); tvSubTitle.setId(ID_SUBTITLE); layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(Utils.dpToPx(context, 20f), 0, Utils.dpToPx(context, 20f), Utils.dpToPx(context, 10f)); linearLayout.addView(tvSubTitle, layoutParams); return linearLayout; }
From source file:com.alibaba.akita.samples.TestFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) { mContent = savedInstanceState.getString(KEY_CONTENT); }//from ww w. j a va 2 s . co m TextView text = new TextView(getActivity()); text.setGravity(Gravity.CENTER); text.setText(mContent); text.setTextSize(20 * getResources().getDisplayMetrics().density); text.setPadding(20, 20, 20, 20); LinearLayout layout = new LinearLayout(getActivity()); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER); layout.addView(text); return layout; }
From source file:com.matthewtamlin.sliding_intro_screen_manual_testing.ButtonFragment.java
/** * @return a LinearLayout which fills its parent */// w w w . j a v a2 s .co m private LinearLayout createLayout() { final LinearLayout layout = new LinearLayout(getContext()); layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return layout; }
From source file:cz.hnutiduha.bioadresar.detail.DetailActivity.java
/** Called when the activity is first created. */ @Override/*from ww w .j a v a2s . c o m*/ public void onCreate(Bundle savedInstanceState) { // NOTE: we do not support saved instance reload (needs farm packing) super.onCreate(null); Intent myIntent = getIntent(); int sourceId = myIntent.getIntExtra(EXTRA_SOURCE, DataSourceFactory.SOURCE_INVALID); long locationId = myIntent.getLongExtra(EXTRA_ID, LocationInfo.INVALID_LOCATION_ID); DataSource source = DataSourceFactory.getDataSource(sourceId, this); if (source == null) { Log.e("view", "unknown source for location"); return; } currentLocation = source.getLocation(locationId); if (currentLocation == null) { Log.e("view", "unknown location"); return; } LinearLayout me = new LinearLayout(this); me.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT)); me.setId(R.id.fragmentContainer); Fragment content = currentLocation.getDetailFragment(this); getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, content).commit(); this.setContentView(me); MenuHandler.installDropDown(getSupportActionBar(), this); }
From source file:org.openpilot_nonag.androidgcs.PfdActivity.java
private View createUI() { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); layout.setId(0x101);/* w ww.j a v a 2 s . c o m*/ { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(0x101, new PFD()); fragmentTransaction.commit(); } return layout; }
From source file:com.shafiq.mytwittle.view.PlaceholderPagerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) { mContent = savedInstanceState.getString(KEY_CONTENT); }/*ww w . ja v a 2 s . c o m*/ TextView text = new TextView(getActivity()); text.setGravity(Gravity.CENTER); text.setText(mContent); text.setTextSize(20 * getResources().getDisplayMetrics().density); text.setPadding(20, 20, 20, 20); LinearLayout layout = new LinearLayout(getActivity()); layout.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER); layout.addView(text); setInitialDownloadState(InitialDownloadState.DOWNLOADED); return layout; }
From source file:com.krg.ParallaxScrollView.sample.PagerViewBackgroundActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create ParallaxScrollView, which will eventually be the container for everything. ParallaxScrollView parallaxScrollView = new ParallaxScrollView(this); parallaxScrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // Create the Background View, a ViewPager. ViewPager backgroundViewPager = new ViewPager(this); backgroundViewPager.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 600)); ImageAdapter adapter = new ImageAdapter(this); backgroundViewPager.setAdapter(adapter); // Create the Contents View. LinearLayout contentView = new LinearLayout(this); contentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); contentView.setBackgroundColor(0xffffffff); int padding = getResources().getDimensionPixelSize(R.dimen.content_padding); contentView.setPadding(padding, padding, padding, padding); TextView textView = new TextView(this); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setText(R.string.starry_night); float textSize = getResources().getDimension(R.dimen.content_text_size); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); contentView.addView(textView);//from w w w. j a va 2s. c o m // Make the ParallaxScrollView aware of the Background, Content, and Header Views, and set the content of // this view to the ParallaxScrollView. parallaxScrollView.setBackgroundView(backgroundViewPager); parallaxScrollView.setContentView(contentView); setContentView(parallaxScrollView); }
From source file:com.tweetlanes.android.core.view.PlaceholderPagerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) { mContent = savedInstanceState.getString(KEY_CONTENT); }//from ww w .ja v a2 s . c o m TextView text = new TextView(getActivity()); text.setGravity(Gravity.CENTER); text.setText(mContent); text.setTextSize(20 * getResources().getDisplayMetrics().density); text.setPadding(20, 20, 20, 20); LinearLayout layout = new LinearLayout(getActivity()); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER); layout.addView(text); setInitialDownloadState(InitialDownloadState.DOWNLOADED); return layout; }