List of usage examples for android.widget LinearLayout HORIZONTAL
int HORIZONTAL
To view the source code for android.widget LinearLayout HORIZONTAL.
Click Source Link
From source file:com.haomee.view.PagerSlidingTabStrip.java
private void addTextIconTab(final int position, String title, int resId) { if (resId == TitleIconTabProvider.NONE_ICON) { addTextTab(position, title);// w w w. ja v a 2 s .co m return; } TextView tab = new TextView(getContext()); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); ImageView icon = new ImageView(getContext()); icon.setImageResource(resId); LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.addView(tab, defaultTabLayoutParams); linearLayout.addView(icon, defaultTabLayoutParams); addTab(position, linearLayout); }
From source file:de.azapps.mirakel.custom_views.TaskDetailDueReminder.java
private void handleMultiline(final int width) { if (this.type == null || this.type != Type.COMBINED) { return;/*w w w . j a va 2 s. c o m*/ } setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); if (width < TaskDetailDueReminder.MIN_DUE_NEXT_TO_REMINDER_SIZE) { this.mainWrapper.setOrientation(LinearLayout.VERTICAL); final android.view.ViewGroup.LayoutParams dueParams = this.dueWrapper.getLayoutParams(); this.dueWrapper.setLayoutParams(new LayoutParams(dueParams.width, dueParams.height, 1.0F)); final android.view.ViewGroup.LayoutParams reminderParams = this.reminderWrapper.getLayoutParams(); this.reminderWrapper .setLayoutParams(new LayoutParams(reminderParams.width, reminderParams.height, 1.0F)); } else { this.mainWrapper.setOrientation(LinearLayout.HORIZONTAL); final android.view.ViewGroup.LayoutParams dueParams = this.dueWrapper.getLayoutParams(); this.dueWrapper.setLayoutParams(new LayoutParams(dueParams.width, dueParams.height, 0.33f)); final android.view.ViewGroup.LayoutParams reminderParams = this.reminderWrapper.getLayoutParams(); this.reminderWrapper .setLayoutParams(new LayoutParams(reminderParams.width, reminderParams.height, 0.66f)); } this.dueWrapper.invalidate(); this.reminderWrapper.invalidate(); setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); invalidate(); }
From source file:com.woodblockwithoutco.quickcontroldock.ui.ControlService.java
public void attachTemporaryView(Drawable icon, String appName) { LinearLayout l = new LinearLayout(getApplicationContext()); l.setGravity(Gravity.CENTER_VERTICAL); l.setOrientation(LinearLayout.HORIZONTAL); l.setPadding(NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX); l.setBackgroundResource(R.drawable.notification_toast_bg); TextView tv = new TextView(getApplicationContext()); tv.setGravity(Gravity.CENTER);/*from w w w.j av a2 s . c o m*/ tv.setCompoundDrawablePadding(COMPOUND_DRAWABLE_PADDING_PX); tv.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); String notificationText = getString(R.string.notification_from) + "\n" + appName; tv.setText(notificationText); tv.setTextColor(COLOR_WHITE); l.addView(tv); Toast toast = new Toast(getApplicationContext()); toast.setView(l); toast.show(); }
From source file:com.doodle.android.chips.ChipsView.java
private void init() { mDensity = getResources().getDisplayMetrics().density; mChipsContainer = new RelativeLayout(getContext()); addView(mChipsContainer);/* w w w . ja v a2 s . c o m*/ // Dummy item to prevent AutoCompleteTextView from receiving focus LinearLayout linearLayout = new LinearLayout(getContext()); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(0, 0); linearLayout.setLayoutParams(params); linearLayout.setFocusable(true); linearLayout.setFocusableInTouchMode(true); mChipsContainer.addView(linearLayout); mEditText = new ChipsEditText(getContext(), this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.topMargin = (int) (SPACING_TOP * mDensity); layoutParams.bottomMargin = (int) (SPACING_BOTTOM * mDensity) + mVerticalSpacing; mEditText.setLayoutParams(layoutParams); mEditText.setMinHeight((int) (CHIP_HEIGHT * mDensity)); mEditText.setPadding(0, 0, 0, 0); mEditText.setLineSpacing(mVerticalSpacing, (CHIP_HEIGHT * mDensity) / mEditText.getLineHeight()); mEditText.setBackgroundColor(Color.argb(0, 0, 0, 0)); mEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_UNSPECIFIED); mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE); mEditText.setHint(mChipsHintText); mChipsContainer.addView(mEditText); mRootChipsLayout = new ChipsVerticalLinearLayout(getContext(), mVerticalSpacing); mRootChipsLayout.setOrientation(LinearLayout.VERTICAL); mRootChipsLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mRootChipsLayout.setPadding(0, (int) (SPACING_TOP * mDensity), 0, 0); mChipsContainer.addView(mRootChipsLayout); initListener(); if (isInEditMode()) { // preview chips LinearLayout editModeLinLayout = new LinearLayout(getContext()); editModeLinLayout.setOrientation(LinearLayout.HORIZONTAL); mChipsContainer.addView(editModeLinLayout); View view = new Chip("Test Chip", null, new Contact(null, null, "Test", "asd@asd.de", null)).getView(); view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); editModeLinLayout.addView(view); View view2 = new Chip("Indelible", null, new Contact(null, null, "Test", "asd@asd.de", null), true) .getView(); view2.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); editModeLinLayout.addView(view2); } }
From source file:com.secbro.qark.customintent.CreateCustomIntentActivity.java
private void createExtrasView() { LinearLayout topLayout = (LinearLayout) findViewById(R.id.extras_key_value_container); LinearLayout.LayoutParams llpTextView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llpTextView.setMargins(10, 20, 10, 10); // llp.setMargins(left, top, right, bottom); LinearLayout.LayoutParams llpEditText = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); llpEditText.setMargins(10, 20, 10, 10); // llp.setMargins(left, top, right, bottom); //key//from w ww . java 2 s . com LinearLayout keyLinearLayout = new LinearLayout(this); keyLinearLayout.setOrientation(LinearLayout.HORIZONTAL); TextView keyTextView = new TextView(this); keyTextView.setText(getResources().getString(R.string.intent_extras_key)); keyTextView.setLayoutParams(llpTextView); AutoCompleteTextView keyEditText = new AutoCompleteTextView(this); keyEditText.setLayoutParams(llpEditText); ArrayAdapter<String> adapter3 = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.intent_extras_array)); keyEditText.setAdapter(adapter3); keyEditText.setSelection(keyEditText.getText().length()); keyEditText.setTag("key_field"); keyLinearLayout.addView(keyTextView); keyLinearLayout.addView(keyEditText); //value LinearLayout valueLinearLayout = new LinearLayout(this); valueLinearLayout.setOrientation(LinearLayout.HORIZONTAL); TextView valueTextView = new TextView(this); valueTextView.setText(getResources().getString(R.string.intent_extras_value)); valueTextView.setLayoutParams(llpTextView); EditText valueEditText = new EditText(this); valueEditText.setTag("value_field"); valueEditText.setLayoutParams(llpEditText); valueLinearLayout.addView(valueTextView); valueLinearLayout.addView(valueEditText); topLayout.addView(keyLinearLayout); topLayout.addView(valueLinearLayout); }
From source file:com.nttec.everychan.http.recaptcha.Recaptcha2fallback.java
@Override public void handle(final Activity activity, final CancellableTask task, final Callback callback) { try {//from w ww .j av a 2s . co m final HttpClient httpClient = ((HttpChanModule) MainApplication.getInstance().getChanModule(chanName)) .getHttpClient(); final String usingURL = scheme + RECAPTCHA_FALLBACK_URL + publicKey + (sToken != null && sToken.length() > 0 ? ("&stoken=" + sToken) : ""); String refererURL = baseUrl != null && baseUrl.length() > 0 ? baseUrl : usingURL; Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, refererURL) }; String htmlChallenge; if (lastChallenge != null && lastChallenge.getLeft().equals(usingURL)) { htmlChallenge = lastChallenge.getRight(); } else { htmlChallenge = HttpStreamer.getInstance().getStringFromUrl(usingURL, HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient, null, task, false); } lastChallenge = null; Matcher challengeMatcher = Pattern.compile("name=\"c\" value=\"([\\w-]+)").matcher(htmlChallenge); if (challengeMatcher.find()) { final String challenge = challengeMatcher.group(1); HttpResponseModel responseModel = HttpStreamer.getInstance().getFromUrl( scheme + RECAPTCHA_IMAGE_URL + challenge + "&k=" + publicKey, HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient, null, task); try { InputStream imageStream = responseModel.stream; final Bitmap challengeBitmap = BitmapFactory.decodeStream(imageStream); final String message; Matcher messageMatcher = Pattern.compile("imageselect-message(?:.*?)>(.*?)</div>") .matcher(htmlChallenge); if (messageMatcher.find()) message = RegexUtils.removeHtmlTags(messageMatcher.group(1)); else message = null; final Bitmap candidateBitmap; Matcher candidateMatcher = Pattern .compile("fbc-imageselect-candidates(?:.*?)src=\"data:image/(?:.*?);base64,([^\"]*)\"") .matcher(htmlChallenge); if (candidateMatcher.find()) { Bitmap bmp = null; try { byte[] imgData = Base64.decode(candidateMatcher.group(1), Base64.DEFAULT); bmp = BitmapFactory.decodeByteArray(imgData, 0, imgData.length); } catch (Exception e) { } candidateBitmap = bmp; } else candidateBitmap = null; activity.runOnUiThread(new Runnable() { final int maxX = 3; final int maxY = 3; final boolean[] isSelected = new boolean[maxX * maxY]; @SuppressLint("InlinedApi") @Override public void run() { LinearLayout rootLayout = new LinearLayout(activity); rootLayout.setOrientation(LinearLayout.VERTICAL); if (candidateBitmap != null) { ImageView candidateView = new ImageView(activity); candidateView.setImageBitmap(candidateBitmap); int picSize = (int) (activity.getResources().getDisplayMetrics().density * 50 + 0.5f); candidateView.setLayoutParams(new LinearLayout.LayoutParams(picSize, picSize)); candidateView.setScaleType(ImageView.ScaleType.FIT_XY); rootLayout.addView(candidateView); } if (message != null) { TextView textView = new TextView(activity); textView.setText(message); CompatibilityUtils.setTextAppearance(textView, android.R.style.TextAppearance); textView.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); rootLayout.addView(textView); } FrameLayout frame = new FrameLayout(activity); frame.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final ImageView imageView = new ImageView(activity); imageView.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageBitmap(challengeBitmap); frame.addView(imageView); final LinearLayout selector = new LinearLayout(activity); selector.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); AppearanceUtils.callWhenLoaded(imageView, new Runnable() { @Override public void run() { selector.setLayoutParams(new FrameLayout.LayoutParams(imageView.getWidth(), imageView.getHeight())); } }); selector.setOrientation(LinearLayout.VERTICAL); selector.setWeightSum(maxY); for (int y = 0; y < maxY; ++y) { LinearLayout subSelector = new LinearLayout(activity); subSelector.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)); subSelector.setOrientation(LinearLayout.HORIZONTAL); subSelector.setWeightSum(maxX); for (int x = 0; x < maxX; ++x) { FrameLayout switcher = new FrameLayout(activity); switcher.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); switcher.setTag(new int[] { x, y }); switcher.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int[] coord = (int[]) v.getTag(); int index = coord[1] * maxX + coord[0]; isSelected[index] = !isSelected[index]; v.setBackgroundColor(isSelected[index] ? Color.argb(128, 0, 255, 0) : Color.TRANSPARENT); } }); subSelector.addView(switcher); } selector.addView(subSelector); } frame.addView(selector); rootLayout.addView(frame); Button checkButton = new Button(activity); checkButton.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); checkButton.setText(android.R.string.ok); rootLayout.addView(checkButton); ScrollView dlgView = new ScrollView(activity); dlgView.addView(rootLayout); final Dialog dialog = new Dialog(activity); dialog.setTitle("Recaptcha"); dialog.setContentView(dlgView); dialog.setCanceledOnTouchOutside(false); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!task.isCancelled()) { callback.onError("Cancelled"); } } }); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); dialog.show(); checkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (task.isCancelled()) return; Async.runAsync(new Runnable() { @Override public void run() { try { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("c", challenge)); for (int i = 0; i < isSelected.length; ++i) if (isSelected[i]) pairs.add(new BasicNameValuePair("response", Integer.toString(i))); HttpRequestModel request = HttpRequestModel.builder() .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")) .setCustomHeaders(new Header[] { new BasicHeader(HttpHeaders.REFERER, usingURL) }) .build(); String response = HttpStreamer.getInstance().getStringFromUrl( usingURL, request, httpClient, null, task, false); String hash = ""; Matcher matcher = Pattern.compile( "fbc-verification-token(?:.*?)<textarea[^>]*>([^<]*)<", Pattern.DOTALL).matcher(response); if (matcher.find()) hash = matcher.group(1); if (hash.length() > 0) { Recaptcha2solved.push(publicKey, hash); activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); } else { lastChallenge = Pair.of(usingURL, response); throw new RecaptchaException( "incorrect answer (hash is empty)"); } } catch (final Exception e) { Logger.e(TAG, e); if (task.isCancelled()) return; handle(activity, task, callback); } } }); } }); } }); } finally { responseModel.release(); } } else throw new Exception("can't parse recaptcha challenge answer"); } catch (final Exception e) { Logger.e(TAG, e); if (!task.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onError(e.getMessage() != null ? e.getMessage() : e.toString()); } }); } } }
From source file:com.witmoon.xmb.ui.widget.PagerSlidingTabStrip.java
private void addTextIconTab(final int position, String title, int resId) { if (resId == TitleIconTabProvider.NONE_ICON) { addTextTab(position, title);//from w ww .j a v a 2 s . com return; } TextView tab = new TextView(getContext()); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); ImageView icon = new ImageView(getContext()); if (position == 1) { icon.setImageResource(icoColor1); } else { icon.setImageResource(selectedIcoColor); } LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.addView(icon, defaultTabLayoutParams); linearLayout.addView(tab, defaultTabLayoutParams); addTab(position, linearLayout); }
From source file:com.grottworkshop.gwsmaterialcalendarview.MaterialCalendarView.java
private void setupChildren() { topbar = new LinearLayout(getContext()); topbar.setOrientation(LinearLayout.HORIZONTAL); topbar.setClipChildren(false);//w w w. ja va 2s . c o m topbar.setClipToPadding(false); addView(topbar, new LayoutParams(1)); buttonPast.setScaleType(ImageView.ScaleType.CENTER_INSIDE); buttonPast.setImageResource(R.drawable.mcv_action_previous); topbar.addView(buttonPast, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1)); title.setGravity(Gravity.CENTER); topbar.addView(title, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, MonthView.DEFAULT_DAYS_IN_WEEK - 2)); buttonFuture.setScaleType(ImageView.ScaleType.CENTER_INSIDE); buttonFuture.setImageResource(R.drawable.mcv_action_next); topbar.addView(buttonFuture, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1)); pager.setId(R.id.mcv_pager); pager.setOffscreenPageLimit(1); addView(pager, new LayoutParams(MonthView.DEFAULT_MONTH_TILE_HEIGHT)); }