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:uk.ac.horizon.artcodes.activity.ExperienceActivity.java

public void copyExperience(View view) {
    if (getExperience().getCanCopy() != null && !getExperience().getCanCopy().booleanValue()) {
        return;/*from   w  w  w  .ja v a2s  .c  o  m*/
    }

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    final LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(layoutParams);
    builder.setTitle(R.string.copy);
    builder.setView(linearLayout);
    final Dialog dialog = builder.create();

    for (final Account account : getServer().getAccounts()) {
        if (!account.canEdit(getUri())) {
            Log.i("copy", "Added " + account.getId());
            AccountItemBinding binding = AccountItemBinding.inflate(getLayoutInflater(), linearLayout, false);
            binding.setAccount(account);
            binding.getRoot().setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                    final Experience experience = getExperience();
                    if (experience.getId() != null && (experience.getId().startsWith("http://")
                            || experience.getId().startsWith("https://"))) {
                        experience.setOriginalID(experience.getId());
                    }
                    experience.setId(null);
                    experience.setName(getString(R.string.copy_of, experience.getName()));
                    experience.getAvailabilities().clear();
                    account.saveExperience(experience);
                    ExperienceActivity.start(ExperienceActivity.this, experience);
                }
            });
            linearLayout.addView(binding.getRoot());
        }
    }

    dialog.show();
}

From source file:com.dwdesign.tweetings.fragment.PullToRefreshListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//w w w  . j av  a 2 s .  c o m
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final 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.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final PullToRefreshListView plv = new PullToRefreshListView(context);
    plv.setOnRefreshListener(this);
    mPullToRefreshListView = plv;

    final ListView lv = plv.getRefreshableView();
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(plv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:org.odk.collect.android.widgets.ExStringWidget.java

public ExStringWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    TableLayout.LayoutParams params = new TableLayout.LayoutParams();
    params.setMargins(7, 5, 7, 5);/*  w  w w.j  ava2 s.  com*/

    // set text formatting
    answer = new EditText(context);
    answer.setId(ViewIds.generateViewId());
    answer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, answerFontsize);
    answer.setLayoutParams(params);
    textBackground = answer.getBackground();
    answer.setBackground(null);
    answer.setTextColor(ContextCompat.getColor(context, R.color.primaryTextColor));

    // capitalize nothing
    answer.setKeyListener(new TextKeyListener(Capitalize.NONE, false));

    // needed to make long read only text scroll
    answer.setHorizontallyScrolling(false);
    answer.setSingleLine(false);

    String s = prompt.getAnswerText();
    if (s != null) {
        answer.setText(s);
    }

    if (formEntryPrompt.isReadOnly() || hasExApp) {
        answer.setFocusable(false);
        answer.setEnabled(false);
    }

    String exSpec = prompt.getAppearanceHint().replaceFirst("^ex[:]", "");
    final String intentName = ExternalAppsUtils.extractIntentName(exSpec);
    final Map<String, String> exParams = ExternalAppsUtils.extractParameters(exSpec);
    final String buttonText;
    final String errorString;
    String v = formEntryPrompt.getSpecialFormQuestionText("buttonText");
    buttonText = (v != null) ? v : context.getString(R.string.launch_app);
    v = formEntryPrompt.getSpecialFormQuestionText("noAppErrorString");
    errorString = (v != null) ? v : context.getString(R.string.no_app);

    launchIntentButton = getSimpleButton(buttonText);
    launchIntentButton.setEnabled(!formEntryPrompt.isReadOnly());
    launchIntentButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(intentName);
            if (isActivityAvailable(i)) {
                try {
                    ExternalAppsUtils.populateParameters(i, exParams,
                            formEntryPrompt.getIndex().getReference());

                    FormController formController = Collect.getInstance().getFormController();
                    if (formController == null) {
                        return;
                    }

                    formController.setIndexWaitingForData(formEntryPrompt.getIndex());
                    fireActivity(i);

                } catch (ExternalParamsException e) {
                    Timber.e(e);
                    onException(e.getMessage());
                }
            } else {
                onException(errorString);
            }
        }

        private void onException(String toastText) {
            hasExApp = false;
            if (!formEntryPrompt.isReadOnly()) {
                answer.setBackground(textBackground);
                answer.setFocusable(true);
                answer.setFocusableInTouchMode(true);
                answer.setEnabled(true);
            }
            launchIntentButton.setEnabled(false);
            launchIntentButton.setFocusable(false);
            cancelWaitingForBinaryData();

            Toast.makeText(getContext(), toastText, Toast.LENGTH_SHORT).show();
            ExStringWidget.this.answer.requestFocus();
            Timber.e(toastText);
        }
    });

    // finish complex layout
    LinearLayout answerLayout = new LinearLayout(getContext());
    answerLayout.setOrientation(LinearLayout.VERTICAL);
    answerLayout.addView(launchIntentButton);
    answerLayout.addView(answer);
    addAnswerView(answerLayout);
}

From source file:cn.thinkjoy.startup.widget.FragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);

        addView(ll, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);//from ww w  . j  a  v  a 2  s .  co  m

        tw.setOrientation(LinearLayout.HORIZONTAL);

        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));
        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);

        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));
        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:org.mariotaku.twidere.fragment.PullToRefreshListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//  w w  w . ja  v a2s  . co m
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new HoloProgressBar(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.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final PullToRefreshListView plv = new PullToRefreshListView(context);
    plv.setOnRefreshListener(this);
    mPullToRefreshListView = plv;

    final ListView lv = plv.getRefreshableView();
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(plv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.matthewtamlin.sliding_intro_screen_manual_testing.TestButtonConfig.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialiseDrawables(); // Needed before tests can run

    // Create a layout to display the control buttons over the ViewPager
    final LinearLayout controlButtonHolder = new LinearLayout(this);
    controlButtonHolder.setOrientation(LinearLayout.VERTICAL);
    getRootView().addView(controlButtonHolder);

    // Add the test buttons to the control layout
    controlButtonHolder.addView(createModifyAppearanceAndBehaviourButton());
    controlButtonHolder.addView(createToggleLeftButtonButton());
    controlButtonHolder.addView(createToggleRightButtonButton());
    controlButtonHolder.addView(createToggleFinalButtonButton());
    controlButtonHolder.addView(createShowLeftButtonOnLastPageButton());
}

From source file:org.musicmod.android.dialog.EqualizerDialog.java

private void setupEqualizerFxAndUI(int audioSessionId) {

    // Create the Equalizer object (an AudioEffect subclass) and attach it
    // to our media player, with a default priority (0).
    mEqualizer = new EqualizerWrapper(0, audioSessionId);
    if (mEqualizer == null) {
        finish();//from w ww.  ja va 2  s  . com
        return;
    }
    mEqualizer.setEnabled(false);

    short bands = mEqualizer.getNumberOfBands();

    final short minEQLevel = mEqualizer.getBandLevelRange()[0];
    final short maxEQLevel = mEqualizer.getBandLevelRange()[1];

    mLinearLayout.removeAllViews();

    for (short i = 0; i < bands; i++) {
        final short band = i;

        TextView freqTextView = new TextView(this);
        freqTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        freqTextView.setGravity(Gravity.CENTER_HORIZONTAL);

        if (mEqualizer.getCenterFreq(band) / 1000 < 1000) {
            freqTextView.setText((mEqualizer.getCenterFreq(band) / 1000) + " Hz");
        } else {
            freqTextView.setText(((float) mEqualizer.getCenterFreq(band) / 1000 / 1000) + " KHz");
        }

        mLinearLayout.addView(freqTextView);

        LinearLayout row = new LinearLayout(this);
        row.setOrientation(LinearLayout.HORIZONTAL);

        TextView minDbTextView = new TextView(this);
        minDbTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        minDbTextView.setText((minEQLevel / 100) + " dB");

        TextView maxDbTextView = new TextView(this);
        maxDbTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        maxDbTextView.setText((maxEQLevel / 100) + " dB");

        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.weight = 1;
        SeekBar bar = new SeekBar(this);
        bar.setLayoutParams(layoutParams);
        bar.setMax(maxEQLevel - minEQLevel);
        bar.setProgress(mPrefs.getEqualizerSetting(band, (short) ((maxEQLevel + minEQLevel) / 2)) - minEQLevel);
        mEqualizer.setBandLevel(band,
                mPrefs.getEqualizerSetting(band, (short) ((maxEQLevel + minEQLevel) / 2)));

        bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

                mEqualizer.setBandLevel(band, (short) (minEQLevel + progress));
                mPrefs.setEqualizerSetting(band, (short) (minEQLevel + progress));
                reloadEqualizer();
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });

        row.addView(minDbTextView);
        row.addView(bar);
        row.addView(maxDbTextView);

        mLinearLayout.addView(row);
    }
}

From source file:org.sufficientlysecure.keychain.remote.ui.SelectPublicKeyFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getContext();
    FrameLayout root = new FrameLayout(context);

    LinearLayout progressContainer = new LinearLayout(context);
    progressContainer.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    progressContainer.setOrientation(LinearLayout.VERTICAL);
    progressContainer.setGravity(Gravity.CENTER);
    progressContainer.setVisibility(View.GONE);

    ProgressBar progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);

    progressContainer.addView(progressBar, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(progressContainer, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    FrameLayout listContainer = new FrameLayout(context);
    listContainer.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView textView = new TextView(context);
    textView.setId(INTERNAL_EMPTY_VIEW_ID);
    textView.setGravity(Gravity.CENTER);

    listContainer.addView(textView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    LinearLayout innerListContainer = new LinearLayout(context);
    innerListContainer.setOrientation(LinearLayout.VERTICAL);

    mSearchView = new EditText(context);
    mSearchView.setId(android.R.id.input);
    mSearchView.setHint(R.string.menu_search);
    mSearchView.setCompoundDrawablesWithIntrinsicBounds(
            ContextCompat.getDrawable(context, R.drawable.ic_search_grey_24dp), null, null, null);

    innerListContainer.addView(mSearchView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    RecyclerView listView = new RecyclerView(context);
    listView.setId(INTERNAL_LIST_VIEW_ID);

    int padding = FormattingUtils.dpToPx(context, 8);
    listView.setPadding(padding, 0, padding, 0);
    listView.setClipToPadding(false);/*from  w  w  w. j a v  a  2s .c o  m*/

    innerListContainer.addView(listView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    listContainer.addView(innerListContainer, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(listContainer, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.bslee.logtoolapk.widget.FragmentTabHost.java

@Deprecated
private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();/*  ww w  . j  ava  2 s  .  co m*/

    super.setOnTabChangedListener(this);

    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}

From source file:com.seo.app.views.FragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);/*from  w ww . ja  v  a2  s  .  c om*/
        tw.setOrientation(TabWidget.HORIZONTAL);
        tw.setShowDividers(0);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    }
}