List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:Main.java
public static LinearLayout setBaseLinearLayout(Context context) { LinearLayout root_layout = new LinearLayout(context); root_layout.setOrientation(LinearLayout.VERTICAL); return root_layout; }
From source file:Main.java
public static View getTestFragmentView(Activity activity, OnClickListener clickListener) { LinearLayout v = new LinearLayout(activity); v.setBackgroundColor(Color.BLUE); v.setOrientation(LinearLayout.VERTICAL); TextView tv1 = new TextView(activity); TextView tv2 = new TextView(activity); Button b1 = new Button(activity); Button b2 = new Button(activity); Button b3 = new Button(activity); b1.setText("reload 1"); b2.setText("reload 2"); b3.setText("reload all"); b1.setId(1);/*w ww.java 2 s . c o m*/ b2.setId(2); b3.setId(3); tv1.setId(android.R.id.text1); tv2.setId(android.R.id.text2); b1.setOnClickListener(clickListener); b2.setOnClickListener(clickListener); b3.setOnClickListener(clickListener); v.addView(tv1); v.addView(tv2); v.addView(b1); v.addView(b2); v.addView(b3); return v; }
From source file:Main.java
private static LinearLayout createLLforAddToCalendar(final Context context, final CheckBox checkBox) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(checkBox);/*from w w w .java 2 s .c om*/ return linearLayout; }
From source file:org.ligi.android.dubwise_uavtalk.dashboard.DownloadDashboardImagesStatusAlertDialog.java
/** * //www .j a v a 2 s.c om * @param activity * @param autoclose - if the alert should close when connection is established * */ public static void show(Context activity, boolean autoclose, Intent after_connection_intent) { LinearLayout lin = new LinearLayout(activity); lin.setOrientation(LinearLayout.VERTICAL); ScrollView sv = new ScrollView(activity); TextView details_text_view = new TextView(activity); LinearLayout lin_in_scrollview = new LinearLayout(activity); lin_in_scrollview.setOrientation(LinearLayout.VERTICAL); sv.addView(lin_in_scrollview); lin_in_scrollview.addView(details_text_view); details_text_view.setText("no text"); ProgressBar progress = new ProgressBar(activity, null, android.R.attr.progressBarStyleHorizontal); progress.setMax(img_lst.length); lin.addView(progress); lin.addView(sv); new AlertDialog.Builder(activity).setTitle("Download Status").setView(lin) .setPositiveButton("OK", new DialogDiscardingOnClickListener()).show(); class AlertDialogUpdater implements Runnable { private Handler h = new Handler(); private TextView myTextView; private ProgressBar myProgress; public AlertDialogUpdater(TextView ab, ProgressBar progress) { myTextView = ab; myProgress = progress; } public void run() { for (int i = 0; i < img_lst.length; i++) { class MsgUpdater implements Runnable { private int i; public MsgUpdater(int i) { this.i = i; } public void run() { myProgress.setProgress(i + 1); if (i != img_lst.length - 1) myTextView.setText("Downloading " + img_lst[i] + ".png"); else myTextView.setText("Ready - please restart DUBwise to apply changes!"); } } h.post(new MsgUpdater(i)); try { URLConnection ucon = new URL(url_lst[i]).openConnection(); BufferedInputStream bis = new BufferedInputStream(ucon.getInputStream()); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) baf.append((byte) current); File path = new File( Environment.getExternalStorageDirectory() + "/dubwise/images/dashboard"); path.mkdirs(); FileOutputStream fos = new FileOutputStream( new File(path.getAbsolutePath() + "/" + img_lst[i] + ".png")); fos.write(baf.toByteArray()); fos.close(); } catch (Exception e) { } try { Thread.sleep(199); } catch (InterruptedException e) { } } } } new Thread(new AlertDialogUpdater(details_text_view, progress)).start(); }
From source file:com.kaedea.frontia.demo.DemoListFragment.java
@SuppressWarnings("ResourceType") public static View getItemViewLayout(Context context) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); int[] attrs = new int[] { R.attr.selectableItemBackground }; TypedArray typedArray = context.obtainStyledAttributes(attrs); int backgroundResource = typedArray.getResourceId(0, 0); linearLayout.setBackgroundResource(backgroundResource); typedArray.recycle();//from w ww . ja va 2 s . co m LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); linearLayout.setLayoutParams(layoutParams); // Title TextView tvTitle = new TextView(context); tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16f); tvTitle.setMaxLines(1); tvTitle.setTextColor(Color.parseColor("#212121")); tvTitle.setId(ID_TITLE); layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(Utils.dpToPx(context, 20f), Utils.dpToPx(context, 10f), Utils.dpToPx(context, 20f), 0); linearLayout.addView(tvTitle, layoutParams); // Sub Title TextView tvSubTitle = new TextView(context); tvSubTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14f); tvSubTitle.setMaxLines(2); tvSubTitle.setTextColor(Color.parseColor("#757575")); tvSubTitle.setId(ID_SUBTITLE); layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(Utils.dpToPx(context, 20f), 0, Utils.dpToPx(context, 20f), Utils.dpToPx(context, 10f)); linearLayout.addView(tvSubTitle, layoutParams); return linearLayout; }
From source file:com.grarak.kerneladiutor.utils.ViewUtils.java
public static Dialog dialogEditTexts(String text, String text2, String hint, String hint2, final DialogInterface.OnClickListener negativeListener, final onDialogEditTextsListener onDialogEditTextListener, Context context) { LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding); layout.setPadding(padding, padding, padding, padding); final AppCompatEditText editText = new AppCompatEditText(context); editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (text != null) { editText.append(text);/* ww w. j a v a 2 s .c o m*/ } if (hint != null) { editText.setHint(hint); } editText.setSingleLine(true); final AppCompatEditText editText2 = new AppCompatEditText(context); editText2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); if (text2 != null) { editText2.setText(text2); } if (hint2 != null) { editText2.setHint(hint2); } editText2.setSingleLine(true); layout.addView(editText); layout.addView(editText2); Dialog dialog = new Dialog(context).setView(layout); if (negativeListener != null) { dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener); } if (onDialogEditTextListener != null) { dialog.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onDialogEditTextListener.onClick(editText.getText().toString(), editText2.getText().toString()); } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (negativeListener != null) { negativeListener.onClick(dialog, 0); } } }); } return dialog; }
From source file:rosmi.acagild.alarmclock.ringing.ShareFragment.java
private static void drawStamp(Context context, Bitmap bitmap, String question) { Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(bitmap, 0, 0, null); float opacity = 0.7f; int horizontalPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()); int verticalPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()); int textSize = 16; // defined in SP int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16, context.getResources().getDisplayMetrics()); LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setBackgroundResource(R.drawable.rounded_corners); layout.getBackground().setAlpha((int) (opacity * 255)); layout.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); ImageView logo = new ImageView(context); logo.setImageDrawable(ContextCompat.getDrawable(context, R.mipmap.ic_launcher)); layout.addView(logo);//from w ww. ja v a 2 s . com TextView textView = new TextView(context); textView.setVisibility(View.VISIBLE); if (question != null) { textView.setText(question); } else { textView.setText("Mimicker"); } textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize); textView.setPadding(horizontalPadding, 0, 0, 0); LinearLayout.LayoutParams centerInParent = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); centerInParent.gravity = Gravity.CENTER_VERTICAL; layout.addView(textView, centerInParent); layout.measure(canvas.getWidth(), height); layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight()); canvas.translate(horizontalPadding, (float) (canvas.getHeight() * 0.8 - height)); float scale = Math.min(1.0f, canvas.getWidth() / 1080f); canvas.scale(scale, scale); layout.draw(canvas); }
From source file:com.microsoft.mimickeralarm.ringing.ShareFragment.java
private static void drawStamp(Context context, Bitmap bitmap, String question) { Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(bitmap, 0, 0, null); float opacity = 0.7f; int horizontalPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()); int verticalPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()); int textSize = 16; // defined in SP int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16, context.getResources().getDisplayMetrics()); LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setBackgroundResource(R.drawable.rounded_corners); layout.getBackground().setAlpha((int) (opacity * 255)); layout.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); ImageView logo = new ImageView(context); logo.setImageDrawable(ContextCompat.getDrawable(context, R.mipmap.ic_launcher_no_bg)); layout.addView(logo);/*from w w w . j a va2 s. c o m*/ TextView textView = new TextView(context); textView.setVisibility(View.VISIBLE); if (question != null) { textView.setText(question); } else { textView.setText("Mimicker"); } textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize); textView.setPadding(horizontalPadding, 0, 0, 0); LinearLayout.LayoutParams centerInParent = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); centerInParent.gravity = Gravity.CENTER_VERTICAL; layout.addView(textView, centerInParent); layout.measure(canvas.getWidth(), height); layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight()); canvas.translate(horizontalPadding, (float) (canvas.getHeight() * 0.8 - height)); float scale = Math.min(1.0f, canvas.getWidth() / 1080f); canvas.scale(scale, scale); layout.draw(canvas); }
From source file:com.tinfoil.sms.sms.KeyExchangeManager.java
/** * Set the shared secrets for the contacts. * @param context The context of the setting. * @param number The Number of the contact. * @param name The name of the contact//w w w . jav a2 s .co m * @param entry The key exchange message. */ private static void setAndSend(final Context context, final Number number, String name, final Entry entry) { final DBAccessor dba = new DBAccessor(context); AlertDialog.Builder builder = new AlertDialog.Builder(context); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); final EditText sharedSecret1 = new EditText(context); sharedSecret1.setHint(context.getString(R.string.shared_secret_hint_1)); sharedSecret1.setMaxLines(EditNumber.SHARED_INFO_MAX); sharedSecret1.setInputType(InputType.TYPE_CLASS_TEXT); linearLayout.addView(sharedSecret1); final EditText sharedSecret2 = new EditText(context); sharedSecret2.setHint(context.getString(R.string.shared_secret_hint_2)); sharedSecret2.setMaxLines(EditNumber.SHARED_INFO_MAX); sharedSecret2.setInputType(InputType.TYPE_CLASS_TEXT); linearLayout.addView(sharedSecret2); builder.setMessage(context.getString(R.string.set_shared_secrets) + " " + name + ", " + number.getNumber()) .setTitle(R.string.set_shared_secrets_title).setCancelable(true) .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { //Save the shared secrets String s1 = sharedSecret1.getText().toString(); String s2 = sharedSecret2.getText().toString(); if (SMSUtility.checksharedSecret(s1) && SMSUtility.checksharedSecret(s2)) { number.setSharedInfo1(s1); number.setSharedInfo2(s2); dba.updateNumberRow(number, number.getNumber(), number.getId()); respondKeyExchangeMessage(context, number, entry); } else { Toast.makeText(context, R.string.invalid_secrets, Toast.LENGTH_LONG).show(); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { //Cancel the key exchange Toast.makeText(context, R.string.key_exchange_cancelled, Toast.LENGTH_LONG).show(); } }); AlertDialog alert = builder.create(); alert.setView(linearLayout); alert.show(); }
From source file:com.nextgis.mobile.map.LocalGeoJsonLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, final Uri uri, final LocalGeoJsonLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);// www .j a v a2 s .co m final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); if (!bCreate) { //TODO: style for drawing } new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (bCreate) { create(map, input.getText().toString(), uri); } else { layer.setName(input.getText().toString()); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }