Example usage for android.widget LinearLayout setLayoutParams

List of usage examples for android.widget LinearLayout setLayoutParams

Introduction

In this page you can find the example usage for android.widget LinearLayout setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.github.wakhub.monodict.activity.FlashcardActivity.java

@UiThread
void showAutoPlayAlertDialog() {
    if (autoPlayDialog != null) {
        return;/*from   w  w  w. j  a v  a  2s.  co m*/
    }

    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    layout.setPadding(20, 20, 20, 20);
    autoPlayDisplayText = new TextView(this);
    autoPlayDisplayText.setTypeface(Typeface.DEFAULT_BOLD);
    layout.addView(autoPlayDisplayText);
    autoPlayTranslateText = new TextView(this);
    autoPlayTranslateText.setText(R.string.message_in_processing);
    layout.addView(autoPlayTranslateText);

    autoPlayDialog = new AlertDialog.Builder(this).setTitle(R.string.action_auto_play)
            .setIcon(R.drawable.ic_action_play).setView(layout)
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    autoPlayDisplayText = null;
                    autoPlayTranslateText = null;
                    stopAutoPlay();
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            }).show();
}

From source file:com.mycelium.wallet.activity.modern.RecordsFragment.java

private LinearLayout createRecordViewList(int titleResource, List<Record> records, Record selectedRecord,
        boolean addButton) {
    LinearLayout outer = new LinearLayout(getActivity());
    outer.setOrientation(LinearLayout.VERTICAL);
    outer.setLayoutParams(_outerLayoutParameters);

    // Add title//  w  w w.j  a va  2 s  . c o  m
    if (addButton) {
        // Add both a title and an "+" button
        LinearLayout titleLayout = new LinearLayout(getActivity());
        titleLayout.setOrientation(LinearLayout.HORIZONTAL);
        titleLayout.setLayoutParams(_innerLayoutParameters);
        titleLayout.addView(createTitle(titleResource));
        outer.addView(titleLayout);
    } else {
        outer.addView(createTitle(titleResource));
    }

    if (records.isEmpty()) {
        return outer;
    }

    LinearLayout inner = new LinearLayout(getActivity());
    inner.setOrientation(LinearLayout.VERTICAL);
    inner.setLayoutParams(_innerLayoutParameters);
    // inner.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_pitch_black_slim));
    inner.requestLayout();

    // build only once since it is relatively slow
    final Set<Address> addressSet = _mbwManager.getRecordManager().getWallet(_mbwManager.getWalletMode())
            .getAddressSet();
    // Add records
    for (Record record : records) {
        // Add separator
        inner.addView(createSeparator());

        // Add item
        boolean isSelected = record.address.equals(selectedRecord.address);
        View item = createRecord(outer, record, isSelected, addressSet);
        inner.addView(item);
    }

    if (records.size() > 0) {
        // Add separator
        inner.addView(createSeparator());
    }

    outer.addView(inner);
    return outer;
}

From source file:com.retroteam.studio.retrostudio.EditorLandscape.java

/**
 * Create all the views associated with a track.
 * @param waveDrawableID//  w  w  w .  java2 s  . co m
 * @param projectLoad
 * @return
 */

private ImageView addTrack(int waveDrawableID, boolean projectLoad) {
    //add the track with the measure adder to the view
    //get layout
    LinearLayout track_layout = (LinearLayout) findViewById(R.id.track_layout);

    //create track container
    HorizontalScrollView track_container = new HorizontalScrollView(getApplicationContext());
    track_container.setLayoutParams(new HorizontalScrollView.LayoutParams(
            HorizontalScrollView.LayoutParams.MATCH_PARENT, displaysize.y / 4));
    track_container.setBackground(getResources().getDrawable(R.color.track_container_bg));

    //create grid layout
    GridLayout track_grid = new GridLayout(getApplicationContext());
    track_grid.setColumnCount(100);
    track_grid.setRowCount(1);
    track_grid.setOrientation(GridLayout.HORIZONTAL);
    track_grid.setId(R.id.track_grid);

    //create linear layout for track id and wave
    LinearLayout track_identifier = new LinearLayout(getApplicationContext());
    track_identifier.setLayoutParams(new LinearLayout.LayoutParams(displaysize.x / 14, displaysize.y / 4));
    track_identifier.setOrientation(LinearLayout.VERTICAL);
    track_identifier.setBackgroundColor(getResources().getColor(R.color.black_overlay));

    //create textview for linear layout
    TextView track_num = new TextView(getApplicationContext());
    track_num.setText("1");
    track_num.setTextSize(45);
    track_num.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL);

    //create imageview for linear layout
    ImageView track_type = new ImageView(getApplicationContext());
    track_type.setImageResource(waveDrawableID);
    track_type.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    //create "add measure" for grid layout
    ImageView add_measure = new ImageView(getApplicationContext());
    add_measure.setImageResource(R.drawable.measure_new);
    add_measure.setLayoutParams(new LinearLayout.LayoutParams((int) (displaysize.x / 3.32),
            LinearLayout.LayoutParams.MATCH_PARENT));
    if (projectLoad) {
        add_measure.setTag(R.id.TAG_ROW, trackReloadCounter);
        add_measure.setId(trackReloadCounter + 4200);
    } else {
        add_measure.setTag(R.id.TAG_ROW, theproject.size() - 1);
        add_measure.setId(theproject.size() - 1 + 4200);
    }

    add_measure.setTag(R.id.TAG_COLUMN, 0);
    add_measure.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addMeasure(v, false);

        }
    });

    track_identifier.addView(track_num);
    if (projectLoad) {
        track_num.setText(Integer.toString(trackReloadCounter + 1));
        trackReloadCounter += 1;
    } else {
        track_num.setText(Integer.toString(theproject.size()));
    }
    track_num.setTextSize(45);
    track_identifier.addView(track_type);

    track_grid.addView(track_identifier);
    track_grid.addView(add_measure);

    track_container.addView(track_grid);

    track_layout.addView(track_container);

    return add_measure;

}

From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java

private void ensureTitle() {
    if (!TextUtils.isEmpty(titleText) || !TextUtils.isEmpty(messageText)) {
        LinearLayout titleContainer = new LinearLayout(getActivity());
        titleContainer.setOrientation(LinearLayout.VERTICAL);
        titleContainer.setGravity(Gravity.CENTER);
        titleContainer.setBackgroundColor(Color.WHITE);
        titleContainer
                .setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(56)));

        if (!TextUtils.isEmpty(titleText)) {
            TextView title = new TextView(getActivity());
            title.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
            title.setText(titleText);//  w w  w. jav  a 2 s.com
            title.setGravity(Gravity.CENTER_HORIZONTAL);
            title.setTextColor(COLOR_TITLE);
            title.getPaint().setFakeBoldText(true);
            titleContainer.addView(title);
        }

        if (!TextUtils.isEmpty(messageText)) {
            TextView message = new TextView(getActivity());
            message.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
            message.setGravity(Gravity.CENTER_HORIZONTAL);
            message.setText(messageText);
            message.setTextColor(COLOR_TITLE);
            titleContainer.addView(message);
        }

        titleContainer.setClickable(true);
        titleContainer.setFocusableInTouchMode(true);

        sheetContainer.addView(titleContainer);
        sheetContainer.addView(createLine());
    }
}

From source file:com.woxthebox.draglistview.KanbanBoardView.java

public DragItemRecyclerView addColumnList(final DragItemAdapter adapter, final View header,
        boolean hasFixedItemSize) {
    final DragItemRecyclerView recyclerView = new DragItemRecyclerView(getContext());
    recyclerView.setMotionEventSplittingEnabled(false);
    recyclerView.setDragItem(mDragItem);
    recyclerView.setLayoutParams(/*from   w  ww  .ja v  a  2 s.  c  o m*/
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setHasFixedSize(hasFixedItemSize);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setDragItemListener(new DragItemRecyclerView.DragItemListener() {
        @Override
        public void onDragStarted(int itemPosition, float x, float y) {
            mDragStartColumn = getColumnOfList(recyclerView);
            mDragStartRow = itemPosition;
            mCurrentRecyclerView = recyclerView;
            mDragItem.setOffset(((View) mCurrentRecyclerView.getParent()).getX(), mCurrentRecyclerView.getY());
            if (mBoardListener != null) {
                mBoardListener.onItemDragStarted(mDragStartColumn, mDragStartRow);
            }
            invalidate();
        }

        @Override
        public void onDragging(int itemPosition, float x, float y) {
        }

        @Override
        public void onDragEnded(int newItemPosition) {
            if (mBoardListener != null) {
                mBoardListener.onItemDragEnded(mDragStartColumn, mDragStartRow, getColumnOfList(recyclerView),
                        newItemPosition);
            }
        }
    });

    recyclerView.setAdapter(adapter);
    recyclerView.setDragEnabled(mDragEnabled);
    adapter.setDragStartedListener(new DragItemAdapter.DragStartCallback() {
        @Override
        public boolean startDrag(View itemView, long itemId) {
            return recyclerView.startDrag(itemView, itemId, getListTouchX(recyclerView),
                    getListTouchY(recyclerView));
        }

        @Override
        public boolean isDragging() {
            return recyclerView.isDragging();
        }
    });

    LinearLayout layout = new LinearLayout(getContext());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(mColumnWidth, LayoutParams.MATCH_PARENT));
    if (header != null) {
        header.setOnTouchListener(new HeaderTouchListener());
        layout.addView(header);
        mHeaders.put(mLists.size(), header);
    }
    layout.addView(recyclerView);

    mLists.add(recyclerView);
    mColumnLayout.addView(layout);
    return recyclerView;
}

From source file:ru.moscow.tuzlukov.sergey.weatherlog.MainActivity.java

private void makePlot(double minTemp, double maxTemp) {
    //all graphics should have a room, to be visible in plot viewport, i.e. max from greatest and min from the least ordinates:
    double lowLimit = Math.min(Math.round(minTemp), temperatureLimit2);
    double highLimit = Math.max(Math.round(maxTemp), temperatureLimit1);
    //round for drawing scale with 5-degrees step:
    lowLimit = Math.floor(lowLimit / 5.0) * 5.0;
    highLimit = Math.ceil(highLimit / 5.0) * 5.0;

    //fill in the plot with all data series:
    List<DataPoint> dataPoints = new ArrayList<>();
    for (Long time : temperatureMap.keySet())
        dataPoints.add(new DataPoint(time, temperatureMap.get(time)));
    dataPoints.add(new DataPoint(currentTime, dataPoints.get(dataPoints.size() - 1).getY())); //fix for using data from cache
    LineGraphSeries<DataPoint> temperatureSeries = new LineGraphSeries<>(
            dataPoints.toArray(new DataPoint[dataPoints.size()]));
    LineGraphSeries<DataPoint> temperatureLimit1Series = new LineGraphSeries<>(
            new DataPoint[] { new DataPoint(currentTimeMinus24h, temperatureLimit1),
                    new DataPoint(currentTime, temperatureLimit1) });
    LineGraphSeries<DataPoint> temperatureLimit2Series = new LineGraphSeries<>(
            new DataPoint[] { new DataPoint(currentTimeMinus24h, temperatureLimit2),
                    new DataPoint(currentTime, temperatureLimit2) });
    graphView.addSeries(temperatureSeries);
    graphView.addSeries(temperatureLimit1Series);
    graphView.addSeries(temperatureLimit2Series);

    //lay out the plot:
    GridLabelRenderer gridLabelRenderer = graphView.getGridLabelRenderer();
    Viewport viewport = graphView.getViewport();
    //adjust grid settings:
    gridLabelRenderer.setGridStyle(GridLabelRenderer.GridStyle.BOTH);
    gridLabelRenderer.setHighlightZeroLines(true);
    gridLabelRenderer.setHorizontalLabelsVisible(false);
    gridLabelRenderer.setVerticalLabelsVisible(true);
    //tune view of lines:
    viewport.setBackgroundColor(getResources().getColor(R.color.plot_viewport_background_color));
    temperatureSeries.setColor(getResources().getColor(R.color.temperature_series_color));
    temperatureSeries.setThickness(2);//from w ww. ja  v  a 2 s  . co  m
    temperatureLimit1Series.setColor(getResources().getColor(R.color.limit1_series_color));
    temperatureLimit1Series.setThickness(2);
    temperatureLimit2Series.setColor(getResources().getColor(R.color.limit2_series_color));
    temperatureLimit2Series.setThickness(2);
    //set viewport bounds and set the scale:
    //...in horizontal:
    gridLabelRenderer.setNumHorizontalLabels(2);
    viewport.setMinX(currentTimeMinus24h);
    viewport.setMaxX(currentTime);
    viewport.setXAxisBoundsManual(true);
    //...in vertical:
    int numVerticalLabels = (int) (highLimit - lowLimit) / 5 + 1;
    numVerticalLabels = numVerticalLabels < 2 ? 2 : numVerticalLabels;
    gridLabelRenderer.setNumVerticalLabels(numVerticalLabels);
    viewport.setMinY(lowLimit);
    viewport.setMaxY(highLimit);
    viewport.setYAxisBoundsManual(true);
    //set horizontal labels:
    LinearLayout llHorizontalLabels = (LinearLayout) findViewById(R.id.llHorizontalLabels);
    if (llHorizontalLabels.getChildCount() == 0) {
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llHorizontalLabels.getLayoutParams();
        params.bottomMargin = 0;
        llHorizontalLabels.setLayoutParams(params);
        gridLabelRenderer.setTextSize(gridLabelRenderer.getTextSize() - 2); //make text a bit smaller
        for (int n = -24; n < 0; n += 3) {
            TextView textView = new TextView(MainActivity.this);
            textView.setText(String.valueOf(n));
            textView.setGravity(Gravity.START);
            textView.setSingleLine();
            params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f / 8.0f);
            textView.setLayoutParams(params);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, gridLabelRenderer.getTextSize());
            textView.setTextColor(gridLabelRenderer.getVerticalLabelsColor());
            llHorizontalLabels.addView(textView);
        }
        TextView tvZeroLabel = (TextView) findViewById(R.id.tvZeroLabel);
        tvZeroLabel.setText("-0 " + getString(R.string.hours_caption));
        tvZeroLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, gridLabelRenderer.getTextSize());
        tvZeroLabel.setTextColor(gridLabelRenderer.getVerticalLabelsColor());
        tvZeroLabel.setVisibility(View.VISIBLE);
        gridLabelRenderer.setPadding(gridLabelRenderer.getPadding() + 2); //make plot a bit smaller
    }
}

From source file:com.todoroo.astrid.activity.TaskEditFragment.java

public static void setViewHeightBasedOnChildren(LinearLayout view) {

    int totalHeight = 0;
    int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(), MeasureSpec.AT_MOST);
    for (int i = 0; i < view.getChildCount(); i++) {
        View listItem = view.getChildAt(i);
        listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
        totalHeight += listItem.getMeasuredHeight();
    }//from w  w  w.ja  v a 2s  .co  m

    ViewGroup.LayoutParams params = view.getLayoutParams();
    if (params == null)
        return;

    params.height = totalHeight;
    view.setLayoutParams(params);
    view.requestLayout();
}

From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java

/**
 * Attach display logic to bottom sheet behavior.
 *//*from w  w w  . ja  va2s . c  om*/
private void setUpBottomSheetFragment() {
    final FragmentManager fm = getSupportFragmentManager();
    BottomSheetFragment mBottomSheetFragment = (BottomSheetFragment) fm
            .findFragmentById(R.id.bottom_sheet_view);

    if (mBottomSheetFragment == null) {
        mBottomSheetFragment = BottomSheetFragment.newInstance();
        ActivityUtils.addFragmentToActivity(fm, mBottomSheetFragment, R.id.bottom_sheet_view,
                getString(R.string.fragment_summary));
        mBottomSheetPresenter = new BottomSheetPresenter(mBottomSheetFragment);
    }

    mBottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet_view));
    if (mBottomSheetBehavior != null) {
        mBottomSheetBehavior.setHideable(true);
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);

        mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
            @Override
            public void onStateChanged(@NonNull final View bottomSheet, final int newState) {
                invalidateOptionsMenu();

                if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
                    showBottomSheetContent();
                    mFab.setVisibility(View.VISIBLE);
                    final LinearLayout layout = (LinearLayout) findViewById(R.id.horizontalLinearLayout);
                    final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
                    layoutParams.setMargins(0, 0, 0, 0);
                    layout.setLayoutParams(layoutParams);
                    layout.requestLayout();

                }
                if (newState == BottomSheetBehavior.STATE_EXPANDED) {

                    final LinearLayout layout = (LinearLayout) findViewById(R.id.horizontalLinearLayout);
                    final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
                    final int toolbarSize = findViewById(R.id.toolbar).getHeight();
                    layoutParams.setMargins(0, toolbarSize, 0, 0);
                    layout.setLayoutParams(layoutParams);
                    layout.requestLayout();
                }
                if (newState == BottomSheetBehavior.STATE_HIDDEN) {
                    final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.chartContainer);
                    if (fragment == null) {
                        mFab.setVisibility(View.VISIBLE);
                    } else {
                        mFab.setVisibility(View.INVISIBLE);
                    }
                }
            }

            @Override
            public void onSlide(@NonNull final View bottomSheet, final float slideOffset) {

                final float scaleFactor = 1 - slideOffset;
                if (mFab != null) {
                    if (scaleFactor <= 1) {
                        mFab.setVisibility(View.VISIBLE);
                        mFab.animate().scaleX(1 - slideOffset).scaleY(1 - slideOffset).setDuration(0).start();
                    }
                    if (slideOffset == 1.00f) {
                        mFab.setVisibility(View.INVISIBLE);
                    }
                }
            }
        });
    }
}

From source file:com.doodle.android.chips.ChipsView.java

private void init() {
    mDensity = getResources().getDisplayMetrics().density;

    mChipsContainer = new RelativeLayout(getContext());
    addView(mChipsContainer);/*  w w  w . j av  a2s.c  om*/

    // Dummy item to prevent AutoCompleteTextView from receiving focus
    LinearLayout linearLayout = new LinearLayout(getContext());
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(0, 0);
    linearLayout.setLayoutParams(params);
    linearLayout.setFocusable(true);
    linearLayout.setFocusableInTouchMode(true);

    mChipsContainer.addView(linearLayout);

    mEditText = new ChipsEditText(getContext(), this);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.topMargin = (int) (SPACING_TOP * mDensity);
    layoutParams.bottomMargin = (int) (SPACING_BOTTOM * mDensity) + mVerticalSpacing;
    mEditText.setLayoutParams(layoutParams);
    mEditText.setMinHeight((int) (CHIP_HEIGHT * mDensity));
    mEditText.setPadding(0, 0, 0, 0);
    mEditText.setLineSpacing(mVerticalSpacing, (CHIP_HEIGHT * mDensity) / mEditText.getLineHeight());
    mEditText.setBackgroundColor(Color.argb(0, 0, 0, 0));
    mEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_UNSPECIFIED);
    mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
            | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    mEditText.setHint(mChipsHintText);

    mChipsContainer.addView(mEditText);

    mRootChipsLayout = new ChipsVerticalLinearLayout(getContext(), mVerticalSpacing);
    mRootChipsLayout.setOrientation(LinearLayout.VERTICAL);
    mRootChipsLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mRootChipsLayout.setPadding(0, (int) (SPACING_TOP * mDensity), 0, 0);
    mChipsContainer.addView(mRootChipsLayout);

    initListener();

    if (isInEditMode()) {
        // preview chips
        LinearLayout editModeLinLayout = new LinearLayout(getContext());
        editModeLinLayout.setOrientation(LinearLayout.HORIZONTAL);
        mChipsContainer.addView(editModeLinLayout);

        View view = new Chip("Test Chip", null, new Contact(null, null, "Test", "asd@asd.de", null)).getView();
        view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        editModeLinLayout.addView(view);

        View view2 = new Chip("Indelible", null, new Contact(null, null, "Test", "asd@asd.de", null), true)
                .getView();
        view2.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        editModeLinLayout.addView(view2);
    }
}

From source file:com.example.drugsformarinemammals.Dose_Information.java

public LinearLayout createBorderLayout() {
    LinearLayout border_layout = new LinearLayout(this);
    border_layout.setOrientation(LinearLayout.VERTICAL);
    border_layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    border_layout.setBackgroundResource(R.drawable.layout_border);
    return border_layout;
}