List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:com.zns.comicdroid.dialog.AuthorIllustratorDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final int comicId = getArguments().getInt("ComicId"); final String[] names = getArguments().getStringArray("Names"); LayoutInflater inflater = getActivity().getLayoutInflater(); final LinearLayout parent = new LinearLayout(getActivity()); parent.setOrientation(1); final View viewHead = inflater.inflate(R.layout.dialog_author_illustrator_head, null); parent.addView(viewHead);/*w ww. j a v a 2 s.c o m*/ for (String name : names) { final View view = inflater.inflate(R.layout.dialog_author_illustrator, null); ((TextView) view.findViewById(R.id.tvName)).setText(name); parent.addView(view); } builder.setView(parent); builder.setPositiveButton(getResources().getString(R.string.common_save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String authors = ""; String illustrators = ""; for (int i = 1; i < parent.getChildCount(); i++) //Start at 1 to skip header { View child = parent.getChildAt(i); TextView tvName = (TextView) child.findViewById(R.id.tvName); RadioButton rbAuthor = (RadioButton) child.findViewById(R.id.rbIsAuthor); RadioButton rbIllustrator = (RadioButton) child.findViewById(R.id.rbIsIllustrator); if (rbAuthor.isChecked()) authors += tvName.getText() + ","; if (rbIllustrator.isChecked()) illustrators += tvName.getText() + ","; } authors = authors.replaceAll("[,]+$", ""); illustrators = illustrators.replaceAll("[,]+$", ""); if (mAuthorIllustratorCallback != null) mAuthorIllustratorCallback.onAuthorIllustratorDialogPositiveClick(comicId, authors, illustrators); } }) .setNegativeButton(getResources().getString(R.string.common_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AuthorIllustratorDialogFragment.this.getDialog().cancel(); } }); AlertDialog dialog = builder.create(); return dialog; }
From source file:com.codeslap.topy.BaseMultiPaneActivity.java
public View getTwoColumns(Fragment firstFragment, float firstWeight, Fragment secondFragment, float secondWeight) { LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.HORIZONTAL); int firstId = 1; int secondId = 2; FrameLayout firstLayout = new FrameLayout(this); LinearLayout.LayoutParams firstParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.FILL_PARENT); firstParams.weight = firstWeight;/*from ww w.j a v a2s . c om*/ firstLayout.setLayoutParams(firstParams); firstLayout.setId(firstId); FrameLayout secondLayout = new FrameLayout(this); LinearLayout.LayoutParams secondParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.FILL_PARENT); secondLayout.setLayoutParams(secondParams); secondParams.weight = secondWeight; secondLayout.setId(secondId); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.add(firstId, firstFragment); ft.add(2, secondFragment); ft.commit(); linearLayout.addView(firstLayout); linearLayout.addView(secondLayout); return linearLayout; }
From source file:org.odk.collect.android.fragments.dialogs.RankingWidgetDialog.java
private LinearLayout setUpPositionsLayout(List<String> values) { LinearLayout positionsLayout = new LinearLayout(getContext()); positionsLayout.setOrientation(LinearLayout.VERTICAL); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(0, 0, 10, 0); positionsLayout.setLayoutParams(layoutParams); for (String value : values) { FrameLayout positionLayout = (FrameLayout) LayoutInflater.from(getContext()) .inflate(R.layout.ranking_item, positionsLayout, false); TextView textView = positionLayout.findViewById(R.id.rank_item_text); textView.setText(String.valueOf(values.indexOf(value) + 1)); textView.setTextSize(Collect.getQuestionFontsize()); positionsLayout.addView(positionLayout); }// w w w.java 2s .com return positionsLayout; }
From source file:org.telegram.ui.Components.BotKeyboardView.java
public void setButtons(TLRPC.TL_replyKeyboardMarkup buttons) { botButtons = buttons;//from ww w . j a v a 2 s . co m container.removeAllViews(); buttonViews.clear(); if (buttons != null && botButtons.rows.size() != 0) { isFullSize = !buttons.resize; buttonHeight = !isFullSize ? 42 : (int) Math.max(42, (panelHeight - AndroidUtilities.dp(30) - (botButtons.rows.size() - 1) * AndroidUtilities.dp(10)) / botButtons.rows.size() / AndroidUtilities.density); for (int a = 0; a < buttons.rows.size(); a++) { TLRPC.TL_keyboardButtonRow row = buttons.rows.get(a); LinearLayout layout = new LinearLayout(getContext()); layout.setOrientation(LinearLayout.HORIZONTAL); container.addView(layout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, buttonHeight, 15, a == 0 ? 15 : 10, 15, a == buttons.rows.size() - 1 ? 15 : 0)); float weight = 1.0f / row.buttons.size(); for (int b = 0; b < row.buttons.size(); b++) { TLRPC.KeyboardButton button = row.buttons.get(b); TextView textView = new TextView(getContext()); textView.setTag(button); textView.setTextColor(ContextCompat.getColor(getContext(), R.color.bot_keyboard_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setGravity(Gravity.CENTER); textView.setBackgroundResource(R.drawable.bot_keyboard_button2); textView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); textView.setText(Emoji.replaceEmoji(button.text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); layout.addView(textView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, weight, 0, 0, b != row.buttons.size() - 1 ? 10 : 0, 0)); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { delegate.didPressedButton((TLRPC.KeyboardButton) v.getTag()); } }); buttonViews.add(textView); } } } }
From source file:uwp.cs.edu.parkingtracker.parking.ParkDialogFragment.java
/** * Called after onAttach as part of the fragment lifecycle. * * @param savedInstanceState/*from ww w. j a va 2s . c o m*/ * @return */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder votePopup = new AlertDialog.Builder(getActivity()); votePopup.setTitle("How full is this zone?"); LinearLayout linear = new LinearLayout(getActivity()); linear.setOrientation(LinearLayout.VERTICAL); SeekBar fullnessSlider = new SeekBar(getActivity()); fullnessSlider.setMax(4); fullnessSlider.setPadding(50, 70, 50, -10); final TextView result = new TextView(getActivity()); result.setPadding(20, 10, 10, 10); result.setText("0 %"); linear.addView(fullnessSlider); linear.addView(result); votePopup.setView(linear); fullnessSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int fullness, boolean fromUser) { fullnessValue = fullness; result.setText(fullness * 25 + "%"); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); votePopup.setPositiveButton("Send", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DatabaseExchange.sendVote(zID, fullnessValue * 25); dismiss(); } }); votePopup.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); return votePopup.create(); }
From source file:ovh.ice.icecons.LicenseActivity.java
private void createLayout() { // main centered layout LinearLayout.LayoutParams smallLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); float scale = IceScreenUtils.densityScale(getApplicationContext()); int padding = Math.round(64 * scale); LinearLayout frameLayout = new LinearLayout(this); frameLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); frameLayout.setBackgroundColor(0xffffffff); frameLayout.setGravity(Gravity.CENTER); setContentView(frameLayout);//w ww. j ava 2 s .c o m LinearLayout baseLayout = new LinearLayout(this); baseLayout.setOrientation(LinearLayout.VERTICAL); baseLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); baseLayout.setGravity(Gravity.LEFT); frameLayout.addView(baseLayout); // gpl button LinearLayout sourceLayout = new LinearLayout(this); sourceLayout.setOrientation(LinearLayout.HORIZONTAL); sourceLayout.setLayoutParams(smallLayoutParams); sourceLayout.setGravity(Gravity.CENTER); baseLayout.addView(sourceLayout); LinearLayout sourceClickLayout = new LinearLayout(this); sourceClickLayout.setOrientation(LinearLayout.HORIZONTAL); sourceClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); sourceClickLayout.setGravity(Gravity.CENTER); sourceLayout.addView(sourceClickLayout); sourceClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gplLink(v); } }); TextView sourceText = new TextView(this); sourceText.setText("This program's source code is avaiable under the GNU General Public License v3."); sourceText.setTextSize(24); sourceText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); sourceText.setPadding(padding, padding, padding, padding); sourceClickLayout.addView(sourceText); // cc button LinearLayout imgLayout = new LinearLayout(this); imgLayout.setOrientation(LinearLayout.HORIZONTAL); imgLayout.setLayoutParams(smallLayoutParams); imgLayout.setGravity(Gravity.CENTER); imgLayout.setBackgroundColor(0xff000000); baseLayout.addView(imgLayout); LinearLayout imgClickLayout = new LinearLayout(this); imgClickLayout.setOrientation(LinearLayout.HORIZONTAL); imgClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); imgClickLayout.setGravity(Gravity.CENTER); imgLayout.addView(imgClickLayout); imgClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ccLink(v); } }); TextView aboutText = new TextView(this); aboutText.setText( "All the images included in this program are avaiable under the Creative Commons Attribution Share Alike 4.0 license."); aboutText.setTextSize(24); aboutText.setTextColor(0xffffffff); aboutText.setPadding(padding, padding, padding, padding); imgClickLayout.addView(aboutText); }
From source file:de.nico.asura.activities.AuthWebView1.java
private void checkLogin() { // Layout for Dialog LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText edit_name = new EditText(this); edit_name.setHint(getString(R.string.menu_AuthWeb_1_fiFi)); layout.addView(edit_name);/* ww w. ja v a2s.co m*/ final EditText edit_pass = new EditText(this); edit_pass.setHint(getString(R.string.menu_AuthWeb_1_seFi)); edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); layout.addView(edit_pass); Builder builder = new Builder(this); builder.setTitle(getString(R.string.menu_AuthWeb_1_name)).setCancelable(false).setView(layout) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { firstField = edit_name.getText().toString(); secondField = edit_pass.getText().toString(); // Nothing? if (firstField.length() == 0 || secondField.length() == 0) { Utils.makeShortToast(AuthWebView1.this, getString(R.string.wrong)); checkLogin(); return; } Editor editor = prefs.edit(); editor.putString("firstFirst", firstField); editor.putString("firstSecond", secondField); editor.commit(); openWebView(); } }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { AuthWebView1.this.finish(); } }).show(); }
From source file:re.neutrino.kanji_assist.dictionary_popup.DictionaryBackgroundTask.java
@Override protected void onPostExecute(String result) { if (result == null) { Log.d(debugName, showEntries.toString()); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); for (DictionaryParser.Entry i : showEntries) { addTextView(linearLayout, i); }/* w ww .j a va 2 s .com*/ scrollView.removeAllViews(); scrollView.addView(linearLayout); } else { scrollView.removeAllViews(); addTextView(result); } }
From source file:com.paginatedgallery.PaginatedGalleryAdapter.java
@Override public Object instantiateItem(View collection, int position) { LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenWidth / viewsPerPage)); int size = images.size(); // Log.i(TAG, "Position: "+position + " , Size : "+size); for (int i = 0; i < viewsPerPage; i++) { final int index = position + (position * (viewsPerPage - 1)) + i; Log.i(TAG, "Index: " + index + " , Size : " + size); if (index < size) { View imageView;/*from ww w .j a v a 2s . c o m*/ if (isImageUrl) { imageView = new RemoteImageView(context, (String) images.get(index), errorDrawable, errorDrawable, true); } else { imageView = new ImageView(context); ((ImageView) imageView).setImageDrawable((Drawable) images.get(index)); } // imageView.setTag(index); imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mItemClickListener != null) { mItemClickListener.onItemClick(v, index); } } }); imageView.setLayoutParams(new LayoutParams(screenWidth / viewsPerPage, screenWidth / viewsPerPage)); imageView.setPadding(10, 10, 10, 10); layout.addView(imageView); } } ((ViewPager) collection).addView(layout); return layout; }
From source file:com.secbro.qark.exportedcomponent.exportedactivity.IntentParamsFragment.java
private void createKeyValuePairLayout(String key, LinearLayout topLayout) { LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); TextView keyTextView = new TextView(getActivity()); keyTextView.setTag("key" + key); keyTextView.setText(key);/* ww w .ja va 2s . c om*/ LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llp.setMargins(50, 40, 50, 10); // llp.setMargins(left, top, right, bottom); keyTextView.setLayoutParams(llp); LinearLayout.LayoutParams llp1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); EditText valueEditText = new EditText(getActivity()); valueEditText.setTag("value" + key); valueEditText.setLayoutParams(llp1); linearLayout.addView(keyTextView); linearLayout.addView(valueEditText); topLayout.addView(linearLayout); }