List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:com.example.android.commitcontent.app.ImageKeyboard.java
@Override public View onCreateInputView() { mGifButton = new Button(this); mGifButton.setText("Insert GIF"); mGifButton.setOnClickListener(new View.OnClickListener() { @Override//from w w w . ja v a2s . co m public void onClick(View view) { ImageKeyboard.this.doCommitContent("A waving flag", MIME_TYPE_GIF, mGifFile); } }); mPngButton = new Button(this); mPngButton.setText("Insert PNG"); mPngButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ImageKeyboard.this.doCommitContent("A droid logo", MIME_TYPE_PNG, mPngFile); } }); mWebpButton = new Button(this); mWebpButton.setText("Insert WebP"); mWebpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ImageKeyboard.this.doCommitContent("Android N recovery animation", MIME_TYPE_WEBP, mWebpFile); } }); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(mGifButton); layout.addView(mPngButton); layout.addView(mWebpButton); return layout; }
From source file:com.owncloud.android.ui.activity.FirstRunActivity.java
private void setSlideshowSize(boolean isLandscape) { boolean isProviderOrOwnInstallationVisible = getResources() .getBoolean(R.bool.show_provider_or_own_installation); LinearLayout buttonLayout = findViewById(R.id.buttonLayout); LinearLayout.LayoutParams layoutParams; buttonLayout.setOrientation(isLandscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); LinearLayout bottomLayout = findViewById(R.id.bottomLayout); if (isProviderOrOwnInstallationVisible) { layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } else {//from ww w. ja v a 2 s . c om layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.convertDpToPixel(isLandscape ? 100f : 150f, this)); } bottomLayout.setLayoutParams(layoutParams); }
From source file:com.near.chimerarevo.fragments.ProductFragment.java
private void addRow(String key, String val, int i) { LinearLayout ll = new LinearLayout(getActivity()); ll.setOrientation(LinearLayout.HORIZONTAL); ll.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); if (i % 2 == 1) ll.setBackgroundColor(getResources().getColor(android.R.color.white)); TextView tv1 = new TextView(getActivity()); TextView tv2 = new TextView(getActivity()); tv1.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); tv2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); tv1.setPadding(20, 10, 0, 10);/*from ww w. j a v a 2 s . c o m*/ tv2.setPadding(0, 10, 20, 10); tv1.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "roboto_condensed.ttf")); tv2.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "roboto_light.ttf")); tv1.setTextSize(16); tv2.setTextSize(15); tv1.setText(key); tv2.setText(val); ll.addView(tv1); ll.addView(tv2); lay.addView(ll); }
From source file:edu.cscie71.imm.slacker.plugin.Slacker.java
private void openAuthScreen() { Runnable runnable = new Runnable() { @SuppressLint("NewApi") public void run() { dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true);// w w w.ja v a 2 s . co m LinearLayout mainLayout = new LinearLayout(cordova.getActivity()); mainLayout.setOrientation(LinearLayout.VERTICAL); inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new WebChromeClient()); WebViewClient client = new AuthBrowser(); inAppWebView.setWebViewClient(client); WebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); inAppWebView.loadUrl(authURL + "?client_id=" + slackClientID + "&scope=" + scope); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); mainLayout.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(mainLayout); dialog.show(); dialog.getWindow().setAttributes(lp); } }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:ru.orangesoftware.financisto.widget.AmountInput.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { requestId = EDIT_AMOUNT_REQUEST.incrementAndGet(); LinearLayout v = new LinearLayout(getActivity()); v.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams lpWrapWrap = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);/*from w ww .j a va2 s . com*/ lpWrapWrap.weight = 1; inflater.inflate(R.layout.amount_input, v, true); c = new Controls(v); c.AmountInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), QuickAmountInput.class); intent.putExtra(EXTRA_AMOUNT, getAbsAmountString()); startActivityForResult(intent, requestId); } }); c.CalculatorInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), CalculatorInput.class); intent.putExtra(EXTRA_AMOUNT, getAbsAmountString()); startActivityForResult(intent, requestId); } }); c.primary.setKeyListener(keyListener); c.primary.addTextChangedListener(textWatcher); c.primary.setOnFocusChangeListener(selectAllOnFocusListener); c.secondary.setKeyListener(new DigitsKeyListener(false, false) { @Override public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DEL) { if (content.length() == 0) { c.primary.requestFocus(); int pos = c.primary.getText().length(); c.primary.setSelection(pos, pos); return true; } } return super.onKeyDown(view, content, keyCode, event); } @Override public int getInputType() { return InputType.TYPE_CLASS_PHONE; } }); c.secondary.addTextChangedListener(textWatcher); c.secondary.setOnFocusChangeListener(selectAllOnFocusListener); return v; }
From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java
public void createMessage(ViewGroup l, String text, String button, View.OnClickListener onclick) { RelativeLayout r = new RelativeLayout(getActivity()); r.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); LinearLayout l2 = new LinearLayout(getActivity()); l2.setOrientation(LinearLayout.VERTICAL); RelativeLayout.LayoutParams layoutparams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutparams.addRule(RelativeLayout.CENTER_VERTICAL); l2.setLayoutParams(layoutparams);//from ww w . j av a 2 s . c o m l2.setGravity(Gravity.CENTER_HORIZONTAL); TextView tv = new TextView(getActivity()); LinearLayout.LayoutParams tvparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); tv.setLayoutParams(tvparams); tv.setText(text); tv.setTextSize(23); tv.setPadding(0, 0, 0, toPixels(15)); l2.addView(tv); if (button != null) { Button b = new Button(getActivity()); LinearLayout.LayoutParams bparams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); bparams.setMargins(toPixels(4), toPixels(0), toPixels(4), toPixels(4)); b.setLayoutParams(bparams); b.setId(R.id.reload_button); b.setText(button); b.setTextSize(23); b.setAllCaps(false); b.setTypeface(null, Typeface.NORMAL); b.setOnClickListener(onclick); l2.addView(b); } r.addView(l2); l.addView(r); }
From source file:com.kunalkene1797.blackboxkit.fragments.tools.BuildpropFragment.java
private void addKeyDialog(final String key, final String value, final boolean modify) { LinearLayout dialogLayout = new LinearLayout(getActivity()); dialogLayout.setOrientation(LinearLayout.VERTICAL); dialogLayout.setGravity(Gravity.CENTER); dialogLayout.setPadding(30, 20, 30, 20); final AppCompatEditText keyEdit = new AppCompatEditText(getActivity()); keyEdit.setTextColor(getResources().getColor(Utils.DARKTHEME ? R.color.white : R.color.black)); if (modify)//from w w w . j a va2 s . c o m keyEdit.setText(key.trim()); else keyEdit.setHint(getString(R.string.key)); final AppCompatEditText valueEdit = new AppCompatEditText(getActivity()); valueEdit.setTextColor(getResources().getColor(Utils.DARKTHEME ? R.color.white : R.color.black)); if (modify) valueEdit.setText(value.trim()); else valueEdit.setHint(getString(R.string.value)); dialogLayout.addView(keyEdit); dialogLayout.addView(valueEdit); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(dialogLayout) .setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (modify) overwrite(key.trim(), value.trim(), keyEdit.getText().toString().trim(), valueEdit.getText().toString().trim()); else add(keyEdit.getText().toString().trim(), valueEdit.getText().toString().trim()); } }).show(); }
From source file:com.garage.payless.fragment.FragmentList.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.list_fragment, container, false); DelayAutoCompleteTextView bookTitle = (DelayAutoCompleteTextView) rootView.findViewById(R.id.book_title); bookTitle.setThreshold(4);// w ww. java 2 s . c om bookTitle.setAdapter(new GoodAutoCompleteAdapter(getActivity().getApplicationContext())); bookTitle.setLoadingIndicator((ProgressBar) rootView.findViewById(R.id.progress_bar)); bookTitle.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { LinearLayout basketList = (LinearLayout) rootView.findViewById(R.id.basket); LinearLayout row = new LinearLayout(getActivity().getApplicationContext()); row.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); row.setOrientation(LinearLayout.HORIZONTAL); TextView valueTV = new TextView(getActivity().getApplicationContext()); valueTV.setText((String) adapterView.getItemAtPosition(position)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); row.addView(valueTV); ImageButton cancel = new ImageButton(getActivity().getApplicationContext()); cancel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); cancel.setImageDrawable(Drawable.createFromPath("@android:drawable/ic_menu_close_clear_cancel")); row.addView(cancel); basketList.addView(row); } }); rootView.findViewById(R.id.create_btn).setOnClickListener(this); return rootView; }
From source file:com.example.team04adventure.Controller.OnlineStoryList.java
/** * Shows the help information for this fragment. *//* www .ja va 2 s .co m*/ private void help() { String helpText = "All stories are displayed here. Press a story to read it. Online stories contains all" + "the stories on the server. My stories contains all the stories written by you." + "Cached stories contains all the stories downloaded on your phone that aren't written by you. " + "The 'I'm Feeling Lucky!' button chooses a random story for you from the existing online stories." + "The 'Add Story' button lets you create a new story, and new stories can only be published by creating a" + "new story from here. The 'Sync' button locally mirrors the cached stories with the online stories so that" + "the cached stories are updated."; AlertDialog.Builder adb = new AlertDialog.Builder(this); LinearLayout lila1 = new LinearLayout(this); lila1.setOrientation(1); final TextView helpTextView = new TextView(this); helpTextView.setText(helpText); lila1.addView(helpTextView); adb.setView(lila1); adb.setTitle("Help"); adb.show(); }
From source file:com.xalops.spotifystreamer.fragments.SearchListFragment.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. * * <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. *//*w w w .j a v a2s. co m*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); //QUICK Inflate from XML file //inflater.inflate(R.layout.search_list_detail, root); // ------------------------------------------------------------------ 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.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ RelativeLayout rlayout = new RelativeLayout(context); EditText et = new EditText(getActivity()); et.setId(INTERNAL_SEARCH_FIELD_ID); et.setSingleLine(true); et.setInputType(InputType.TYPE_CLASS_TEXT); et.setImeOptions(EditorInfo.IME_ACTION_DONE); RelativeLayout.LayoutParams etRLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); RelativeLayout.LayoutParams lframeRLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); lframeRLayoutParams.addRule(RelativeLayout.BELOW, INTERNAL_SEARCH_FIELD_ID); 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)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); rlayout.addView(et, etRLayoutParams); rlayout.addView(lframe, lframeRLayoutParams); root.addView(rlayout, 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; }