Example usage for android.widget LinearLayout setOrientation

List of usage examples for android.widget LinearLayout setOrientation

Introduction

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

Prototype

public void setOrientation(@OrientationMode int orientation) 

Source Link

Document

Should the layout be a column or a row.

Usage

From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedMessage.java

@Override
public View getBody(final AppCompatActivity activity, final Integer textColor, final Float textSize,
        final boolean showLinkButtons) {

    final LinearLayout subjectLayout = new LinearLayout(activity);
    subjectLayout.setOrientation(LinearLayout.VERTICAL);

    final TextView subjectText = new TextView(activity);
    subjectText.setText(StringEscapeUtils.unescapeHtml4(src.subject != null ? src.subject : "(no subject)"));
    subjectText.setTextColor(textColor);
    subjectText.setTextSize(textSize);/*from   ww w  .  jav  a  2s . c o m*/
    subjectText.setTypeface(null, Typeface.BOLD);

    subjectLayout.addView(subjectText);
    subjectLayout.addView(body.buildView(activity, textColor, textSize, showLinkButtons));

    return subjectLayout;
}

From source file:freed.cam.ui.themesample.cameraui.HorizontalValuesFragment.java

private LinearLayout getNewLayout() {
    LinearLayout linearLayout = new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(params);
    linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);
    valuesHolder.addView(linearLayout);/*  w  w w.  ja v  a  2s  . c om*/
    return linearLayout;
}

From source file:com.weizoo.game.go.HappyGo.HappyGo.java

private void initAd() {
    try {/*w ww.j  a  va 2  s .c  om*/
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        addContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

        // Create the adView.
        adView = new AdView(this, AdSize.SMART_BANNER, "a152c6a39379a40");

        // Add the adView to it.
        layout.addView(adView);

        // Initiate a generic request.
        AdRequest adRequest = new AdRequest();
        adRequest.addTestDevice("355296050198170");
        // Load the adView with the ad request.
        adView.loadAd(adRequest);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ru.orangesoftware.financisto.widget.QuickAmountInput.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    Activity activity = getActivity();//w w w .ja v a 2  s .  c  om
    LinearLayout layout = new LinearLayout(activity);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setBackgroundColor(ContextCompat.getColor(activity, R.color.calculator_background));

    LinearLayout.LayoutParams lpWrapWrap = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    lpWrapWrap.weight = 1;

    // picker
    Currency currency = CurrencyCache.getCurrencyOrEmpty(currencyId);
    picker = new AmountPicker(activity, currency.decimals);
    layout.addView(picker, lpWrapWrap);
    picker.setCurrent(new BigDecimal(amount));
    picker.setOnChangeListener((picker, oldVal, newVal) -> setTitle());

    // buttons
    LinearLayout buttonsLayout = new LinearLayout(new ContextThemeWrapper(activity, R.style.ButtonBar), null,
            R.style.ButtonBar);
    buttonsLayout.setOrientation(LinearLayout.HORIZONTAL);

    Button bOK = new Button(activity);
    bOK.setText(R.string.ok);
    bOK.setOnClickListener(arg0 -> {
        listener.onAmountChanged(picker.getCurrent().toPlainString());
        dismiss();
    });
    buttonsLayout.addView(bOK, lpWrapWrap);

    Button bClear = new Button(activity);
    bClear.setText(R.string.reset);
    bClear.setOnClickListener(arg0 -> picker.setCurrent(BigDecimal.ZERO));
    buttonsLayout.addView(bClear, lpWrapWrap);

    Button bCancel = new Button(activity);
    bCancel.setText(R.string.cancel);
    bCancel.setOnClickListener(arg0 -> dismiss());

    buttonsLayout.addView(bCancel, lpWrapWrap);
    layout.addView(buttonsLayout,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    return layout;
}

From source file:com.seraphim.chips.ChipsVerticalLinearLayout.java

private LinearLayout createHorizontalView() {
    LinearLayout ll = new LinearLayout(getContext());
    ll.setPadding(0, 0, 0, rowSpacing);//from   w w w  .  j  a  v a  2s  .c  om
    ll.setOrientation(HORIZONTAL);
    ll.setDividerDrawable(ContextCompat.getDrawable(getContext(), R.drawable.amc_empty_vertical_divider));
    ll.setShowDividers(SHOW_DIVIDER_MIDDLE);
    addView(ll);
    lineLayouts.add(ll);
    return ll;
}

From source file:org.inversebit.proto01.main.DiagnoserFragment.java

private void addData(String pText, float pVal) {
    LinearLayout ll = new LinearLayout(getActivity().getBaseContext());
    ll.setOrientation(LinearLayout.VERTICAL);

    TextView tv1 = new TextView(getActivity().getBaseContext());
    tv1.setText(pText);/* w w  w. ja v  a  2  s. c o m*/
    tv1.setTextColor(getResources().getColor(android.R.color.tertiary_text_light));
    tv1.setTextSize(15.0f);
    ll.addView(tv1);

    TextView tv2 = new TextView(getActivity().getBaseContext());
    tv2.setText("\t" + pVal);
    tv2.setTextColor(getResources().getColor(android.R.color.black));
    tv2.setTextSize(15.0f);
    ll.addView(tv2);

    ((LinearLayout) getActivity().findViewById(R.id.dataLayout)).addView(ll);
}

From source file:com.secbro.qark.exportedcomponent.exportedreceiver.IntentSenderFragment.java

private void createKeyValuePairLayout(String key, LinearLayout paramsLayout) {
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    llp.setMargins(50, 10, 50, 10); // llp.setMargins(left, top, right, bottom);
    TextView keyTextView = new TextView(getActivity());
    keyTextView.setTag("key" + key);
    keyTextView.setText(key);/*from ww  w  .j  a va2 s.com*/
    keyTextView.setLayoutParams(llp);

    LinearLayout.LayoutParams llp1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    llp.setMargins(50, 10, 50, 10); // llp.setMargins(left, top, right, bottom);
    EditText valueEditText = new EditText(getActivity());
    valueEditText.setTag("value" + key);
    valueEditText.setLayoutParams(llp1);

    linearLayout.addView(keyTextView);
    linearLayout.addView(valueEditText);
    paramsLayout.addView(linearLayout);
}

From source file:jlelse.simpleuisample.SampleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // FAB/*from   w  ww  . j  ava 2s .c  om*/
    // This way ...
    setFabDrawable(ContextCompat.getDrawable(this, R.mipmap.ic_launcher));
    setFabListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setDrawerEnabled(!isDrawerEnabled());
        }
    });
    setFabEnabled(true);
    // ... or this
    initFab(true, ContextCompat.getDrawable(this, R.mipmap.ic_launcher), new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setDrawerEnabled(!isDrawerEnabled());
        }
    });

    // Toolbar
    // This way ...
    setToolbarEnabled(true);
    // ... or this
    initToolbar(true);

    // Drawer
    // This way ...
    setDrawerMenuResId(R.menu.drawer);
    setDrawerListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem item) {
            new AlertDialog.Builder(SampleActivity.this).setTitle("Test").setMessage("Hey!").show();
            getDrawerLayout().closeDrawers();
            return true;
        }
    });
    TextView headerView = new TextView(this);
    headerView.setText("Hi!");
    setDrawerHeaderView(headerView);
    setDrawerEnabled(true);
    // ... or this
    initDrawer(true, R.menu.drawer, new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem item) {
            new AlertDialog.Builder(SampleActivity.this).setTitle("Test").setMessage("Hey!").show();
            getDrawerLayout().closeDrawers();
            return true;
        }
    }, headerView);

    NestedScrollView contentSV = new NestedScrollView(this);
    LinearLayout content = new LinearLayout(this);
    content.setOrientation(LinearLayout.VERTICAL);
    contentSV.addView(content);
    setContentView(contentSV, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    for (int i = 0; i < 100; i++) {
        TextView sampleTV = new TextView(this);
        sampleTV.setText(R.string.app_name);
        content.addView(sampleTV);
    }
    TextView sampleTV = new TextView(this);
    sampleTV.setText("Last item");
    content.addView(sampleTV);
}

From source file:com.cerema.cloud2.ui.dialog.CredentialsDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    // Create field for username
    mUsernameET = new EditText(getActivity());
    mUsernameET.setHint(getActivity().getText(R.string.auth_username));

    // Create field for password
    mPasswordET = new EditText(getActivity());
    mPasswordET.setHint(getActivity().getText(R.string.auth_password));
    mPasswordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

    // Prepare LinearLayout for dialog
    LinearLayout ll = new LinearLayout(getActivity());
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.addView(mUsernameET);/* ww w.  j  a v  a2  s  .  com*/
    ll.addView(mPasswordET);

    ll.requestFocus();

    setRetainInstance(true);

    Builder authDialog = new AlertDialog.Builder(getActivity())
            .setTitle(getActivity().getText(R.string.saml_authentication_required_text)).setView(ll)
            .setCancelable(false).setPositiveButton(R.string.common_ok, this)
            .setNegativeButton(R.string.common_cancel, this);

    Dialog d = authDialog.create();
    d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

From source file:org.odk.collect.android.fragments.dialogs.RankingWidgetDialog.java

private ScrollView setUpRankingLayout(List<String> values, FormIndex formIndex) {
    LinearLayout rankingLayout = new LinearLayout(getContext());
    rankingLayout.setOrientation(LinearLayout.HORIZONTAL);
    rankingLayout.addView(setUpPositionsLayout(values));
    rankingLayout.addView(setUpRecyclerView(values, formIndex));
    rankingLayout.setPadding(10, 0, 10, 0);

    ScrollView scrollView = new ScrollView(getContext());
    scrollView.addView(rankingLayout);// ww  w .j a v  a 2s  .  com
    return scrollView;
}