List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:com.google.samples.apps.iosched.ui.widget.CollectionView.java
private View makeNewItemRow(RowComputeResult rowInfo) { LinearLayout ll = new LinearLayout(getContext()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.setOrientation(LinearLayout.HORIZONTAL); ll.setLayoutParams(params);/*w w w. jav a 2 s. co m*/ int nbColumns = rowInfo.group.mDisplayCols; if (hasCustomGroupView()) { nbColumns = 1; } for (int i = 0; i < nbColumns; i++) { View view = getItemView(rowInfo, i, null, ll); setupLayoutParams(view); ll.addView(view); } return ll; }
From source file:mn.today.TheHubActivity.java
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1) private AlertDialog.Builder generateCustomDialog(EditText nameInputET) { AlertDialog.Builder newFlowDialog = new AlertDialog.Builder(TheHubActivity.this); //Sets up Layout Parameters LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); params.setMarginStart(42);/* ww w . j av a2 s . com*/ params.setMarginEnd(50); AppUtils.setNameInputFilters(nameInputET); //Adds the ET and params to the layout of the dialog box layout.addView(nameInputET, params); newFlowDialog.setTitle(" ?."); newFlowDialog.setView(layout); return newFlowDialog; }
From source file:com.github.wakhub.monodict.activity.FlashcardActivity.java
@UiThread void showAutoPlayAlertDialog() { if (autoPlayDialog != null) { return;/* w w w .j a v a2 s . com*/ } 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// ww w . j av a2s . 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:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** Presents additional information about a specific assistant. * @return a dynamically generated linear layout *//* ww w.j ava2s .c om*/ private LinearLayout getServiceDescLayout() { final LinearLayout output = new LinearLayout(this); final RelativeLayout topButtonsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); final Button btnBack = new Button(this); btnBack.setText(R.string.btnAllServices); btnBack.setId(5); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { output.setVisibility(View.GONE); getListView().setVisibility(View.VISIBLE); lblAvAssist.setVisibility(View.VISIBLE); } }); topButtonsLayout.addView(btnBack); final Button btnInvoke = new Button(this); btnInvoke.setText(R.string.btnInvokeLabel); btnInvoke.setId(6); btnInvoke.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new InvocationTask().execute(); } }); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId()); btnInvoke.setLayoutParams(layoutParams); topButtonsLayout.addView(btnInvoke); output.addView(topButtonsLayout); TableLayout serviceInfoTbl = new TableLayout(this); output.addView(serviceInfoTbl); serviceInfoTbl.setColumnShrinkable(1, true); /* FIRST ROW */ TableRow rowServiceName = new TableRow(this); TextView lblServiceName = new TextView(this); lblServiceName.setText(R.string.lblServiceName); lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceName = new TextView(this); txtServiceName.setText(selectedService); txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceName.setPadding(10, 0, 0, 0); rowServiceName.addView(lblServiceName); rowServiceName.addView(txtServiceName); /* SECOND ROW */ TableRow rowServiceDesc = new TableRow(this); TextView lblServiceDesc = new TextView(this); lblServiceDesc.setText(R.string.lblServiceDesc); lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceDesc = new TextView(this); txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceDesc.setPadding(10, 0, 0, 0); List<GateRuntimeParameter> params = null; ServiceInfoForClientArray list = getServices(); for (int i = 0; i < list.getItem().size(); i++) { if (list.getItem().get(i).getServiceName().equals(selectedService)) { txtServiceDesc.setText(list.getItem().get(i).getServiceDescription()); params = list.getItem().get(i).getParams(); break; } } TextView lblParams = new TextView(this); lblParams.setText(R.string.lblServiceParams); lblParams.setTextAppearance(getApplicationContext(), R.style.titleText); output.addView(lblParams); LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout paramsLayout = new LinearLayout(this); paramsLayout.setId(0); if (params.size() > 0) { ScrollView scroll = new ScrollView(this); scroll.setLayoutParams(txtParamsAttrbs); paramsLayout.setOrientation(LinearLayout.VERTICAL); scroll.addView(paramsLayout); for (int j = 0; j < params.size(); j++) { TextView lblParamName = new TextView(this); lblParamName.setText(params.get(j).getParamName()); EditText tview = new EditText(this); tview.setId(1); tview.setText(params.get(j).getDefaultValueString()); LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tview.setLayoutParams(txtViewLayoutParams); paramsLayout.addView(lblParamName); paramsLayout.addView(tview); } output.addView(scroll); } else { TextView lblParamName = new TextView(this); lblParamName.setText(R.string.lblRTParams); output.addView(lblParamName); } rowServiceDesc.addView(lblServiceDesc); rowServiceDesc.addView(txtServiceDesc); serviceInfoTbl.addView(rowServiceName); serviceInfoTbl.addView(rowServiceDesc); output.setOrientation(LinearLayout.VERTICAL); output.setGravity(Gravity.TOP); return output; }
From source file:brostore.maquillage.custom.PagerSlidingTabStrip.java
private void addCustomTextTab(final int position, String title) { LinearLayout conteneur = new LinearLayout(getContext()); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); conteneur.setOrientation(LinearLayout.HORIZONTAL); conteneur.setGravity(Gravity.CENTER); TextView tab = new TextView(getContext()); TextView tabCust = new TextView(getContext()); //tabCust.setBackgroundResource(R.drawable.live_nombre); tabCust.setGravity(Gravity.CENTER);/*w w w .j av a2 s. c o m*/ tabCust.setTextColor(Color.WHITE); tabCust.setTypeface(tabTypeface); tabCust.setTextSize(11); tabCust.setVisibility(View.GONE); int fiveDip = Utils.convertDpToPixel(5, getResources()); tabCust.setPadding(fiveDip, 0, fiveDip, 0); tabCust.setText("0"); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); conteneur.addView(tab, param); param.leftMargin = Utils.convertDpToPixel(10, getResources()); conteneur.addView(tabCust, param); addTab(position, conteneur); }
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 www .j ava 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:nz.ac.auckland.lablet.script.components.TextComponent.java
@Override public View createView(Context context, Fragment parent) { ScriptTreeNodeSheetBase.Counter counter = this.component.getCounter("QuestionCounter"); // Note: we have to do this programmatically because findViewById would find the wrong child // items if there is more than one text question. LinearLayout layout = new LinearLayout(context); layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); layout.setOrientation(LinearLayout.VERTICAL); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { layout.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color, null)); } else {//from www. j a va 2 s .com layout.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color)); } TextView textView = new TextView(context); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(android.R.style.TextAppearance_Medium); } else { textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); } question_num = counter.increaseValue(); textView.setText("Q" + question_num + ": " + text); EditText editText = new EditText(context); editText.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); editText.setText(answer); editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { answer = editable.toString(); update(); } }); layout.addView(textView); layout.addView(editText); return layout; }
From source file:org.quantumbadger.redreader.fragments.PostListingFragment.java
private LinearLayout createVerticalLinearLayout(Context context) { final LinearLayout result = new LinearLayout(context); result.setOrientation(LinearLayout.VERTICAL); return result; }