List of usage examples for android.widget TextView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.secbro.qark.exportedcomponent.exportedreceiver.IntentSenderFragment.java
private void createKeyValuePairLayout(String key, LinearLayout paramsLayout) { LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llp.setMargins(50, 10, 50, 10); // llp.setMargins(left, top, right, bottom); TextView keyTextView = new TextView(getActivity()); keyTextView.setTag("key" + key); keyTextView.setText(key);//w w w. j a va 2 s . c o m keyTextView.setLayoutParams(llp); LinearLayout.LayoutParams llp1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); llp.setMargins(50, 10, 50, 10); // llp.setMargins(left, top, right, bottom); EditText valueEditText = new EditText(getActivity()); valueEditText.setTag("value" + key); valueEditText.setLayoutParams(llp1); linearLayout.addView(keyTextView); linearLayout.addView(valueEditText); paramsLayout.addView(linearLayout); }
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 w w . j av a 2s. com 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.google.adsensequickstart.DisplayInventoryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ScrollView sv = new ScrollView(getActivity()); TableLayout tl = new TableLayout(getActivity()); tl.setBackgroundColor(Color.rgb(242, 239, 233)); sv.addView(tl);//from ww w.j a va 2s . c o m if (displayInventoryController == null) { return sv; } Inventory inventory = displayInventoryController.getInventory(); TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tableRowParams.setMargins(1, 1, 1, 1); TableRow.LayoutParams accountLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); accountLayoutParams.setMargins(2, 1, 2, 1); TableRow.LayoutParams adCLientLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); adCLientLayoutParams.setMargins(12, 1, 2, 1); TableRow.LayoutParams adUnitChannelLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); adUnitChannelLayoutParams.setMargins(24, 1, 2, 1); for (String accountId : inventory.getAccounts()) { TableRow trow = new TableRow(getActivity()); tl.addView(trow); TextView tv = new TextView(getActivity()); tv.setText(accountId); trow.addView(tv); tv.setLayoutParams(accountLayoutParams); for (String adClient : inventory.getAdClients(accountId)) { TableRow trow2 = new TableRow(getActivity()); trow2.setBackgroundColor(Color.rgb(214, 204, 181)); tl.addView(trow2); TextView tv2 = new TextView(getActivity()); tv2.setText(adClient); trow2.addView(tv2); tv2.setLayoutParams(adCLientLayoutParams); for (String adUnit : inventory.getAdUnits(adClient)) { TableRow trow3 = new TableRow(getActivity()); trow3.setBackgroundColor(Color.rgb(251, 145, 57)); tl.addView(trow3); TextView tv3 = new TextView(getActivity()); tv3.setText(adUnit); trow3.addView(tv3); tv3.setLayoutParams(adUnitChannelLayoutParams); } for (String customChannel : inventory.getCustomChannels(adClient)) { TableRow trow3 = new TableRow(getActivity()); trow3.setBackgroundColor(Color.rgb(255, 195, 69)); tl.addView(trow3); TextView tv3 = new TextView(getActivity()); tv3.setText(customChannel); trow3.addView(tv3); tv3.setLayoutParams(adUnitChannelLayoutParams); } } } return sv; }
From source file:co.ldln.android.ObjectReadFragment.java
@Override public void onReadSchemaResult(Schema schema) { mSchema = schema;/*from w w w . jav a 2 s. co m*/ HashMap<String, String> keyValueMap = mSyncableObject.getKeyValueMap(); for (SchemaField schemaField : mSchema.getFields(mActivity)) { String label = schemaField.getLabel(); String value = keyValueMap.get(label); String type = schemaField.getType(); // Create a linear layout to hold the field LinearLayout ll = new LinearLayout(mActivity); LayoutParams llParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.setLayoutParams(llParams); ll.setOrientation(LinearLayout.HORIZONTAL); // TODO: different UI for different field types // Default to TextView TextView labelTv = new TextView(mActivity); LayoutParams labelTvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); labelTv.setLayoutParams(labelTvParams); labelTv.setText(label); labelTv.setPadding(0, 0, 20, 0); labelTv.setTypeface(Typeface.DEFAULT_BOLD); ll.addView(labelTv); TextView valueTv = new TextView(mActivity); LayoutParams valueTvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); valueTv.setLayoutParams(valueTvParams); valueTv.setText(value); ll.addView(valueTv); mFormHolder.addView(ll); } }
From source file:jfabrix101.lib.fragmentActivity.AbstractFragmentContent.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mLogger.trace("onCreateView()"); View v = null;// www . ja v a 2s .co m int layout = getFragmentLayout(); if (layout <= 0) { mLogger.warn( "onCreateView() - getFragmentLayout return an invalid value. Creating a default contentView"); TextView view = new TextView(mActivityController); view.setId(android.R.id.content); view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); view.setText("objectMode : " + getActivityObjectModel()); view.setTextSize(22); v = view; } else v = inflater.inflate(layout, container, false); initializeView(v); return v; }
From source file:com.google.android.leanbackjank.presenter.GridItemPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { TextView view = new TextView(parent.getContext()); Resources res = parent.getResources(); int width = res.getDimensionPixelSize(R.dimen.grid_item_width); int height = res.getDimensionPixelSize(R.dimen.grid_item_height); view.setLayoutParams(new ViewGroup.LayoutParams(width, height)); view.setFocusable(true);/*www .j a v a 2 s . c om*/ view.setFocusableInTouchMode(true); view.setBackgroundColor(ResourcesCompat.getColor(parent.getResources(), R.color.jank_yellow, null)); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER); return new ViewHolder(view); }
From source file:com.google.reviewit.AddReviewerFragment.java
private void addReviewerRow(TableLayout tl, AccountInfo reviewer) { TableRow tr = new TableRow(getContext()); tr.setLayoutParams(matchAndWrapTableRowLayout()); ImageView avatar = new ImageView(getContext()); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(widgetUtil.dpToPx(20), widgetUtil.dpToPx(20));//from w w w . ja v a 2 s .c o m layoutParams.setMargins(0, 0, widgetUtil.dpToPx(5), widgetUtil.dpToPx(2)); avatar.setLayoutParams(layoutParams); WidgetUtil.displayAvatar(getApp(), reviewer, avatar); tr.addView(avatar); TextView reviewerName = new TextView(getContext()); reviewerName.setLayoutParams(wrapTableRowLayout()); reviewerName.setText(FormatUtil.format(reviewer)); tr.addView(reviewerName); tl.addView(tr, matchAndWrapTableLayout()); }
From source file:com.picogram.awesomeness.SettingsActivity.java
public boolean onPreferenceClick(final Preference preference) { if (preference.getKey().equals("statistics")) { //TODO/*from w ww. ja v a 2 s .co m*/ Crouton.makeText(this, "This is not yet implemented", Style.INFO).show(); final AlertDialog dialog = new AlertDialog.Builder(this).create(); final String[] scoresTitles = new String[] { "Games Played", "Games Won", "Taps", "Taps per Puzzle", "Tapes per Minute", "Times Played" }; final int gamesPlayed = 0, gamesWon = 0, taps = 0, tapsPerPuzzle = 0, tapsPerMinute = 0, timePlayed = 0; final int[] scores = { gamesPlayed, gamesWon, taps, tapsPerPuzzle, tapsPerMinute, timePlayed }; // TODO: Implement the preferences and what not. final LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i != scores.length; ++i) { final LinearLayout sub = new LinearLayout(this); sub.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); sub.setOrientation(LinearLayout.HORIZONTAL); TextView tv = new TextView(this); tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tv.setText(scoresTitles[i]); sub.addView(tv); tv = new TextView(this); tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tv.setText(scores[i] + ""); sub.addView(tv); ll.addView(sub); } dialog.setView(ll); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogTheme; dialog.show(); dialog.dismiss(); return true; } else if (preference.getKey().equals("changelog")) { // Launch change log dialog final ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this); _ChangelogDialog.show(); } else if (preference.getKey().equals("licenses")) { // Launch the licenses stuff. Dialog ld = new LicensesDialog(this, R.raw.licenses, false, false).create(); ld.getWindow().getAttributes().windowAnimations = R.style.DialogTheme; ld.show(); } else if (preference.getKey().equals("email")) { final String email = "warner.73+Picogram@wright.edu"; final String subject = "Picogram - <SUBJECT>"; final String message = "Picogram,\n\n<MESSAGE>"; // Contact me. final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, message); emailIntent.setType("message/rfc822"); this.startActivity(Intent.createChooser(emailIntent, "Send Mail Using :")); overridePendingTransition(R.anim.fadein, R.anim.exit_left); } else if (preference.getKey().equals("rateapp")) { // TODO fix this when we publish. this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=Picogram"))); overridePendingTransition(R.anim.fadein, R.anim.exit_left); final Editor editor = this.prefs.edit(); editor.putBoolean(RateMeMaybe.PREF.DONT_SHOW_AGAIN, true); editor.commit(); } else if (preference.getKey().equals("logoutgoogle")) { //TODO Crouton.makeText(this, "This is not currently supported.", Style.INFO).show(); } else if (preference.getKey().equals("logoutfacebook")) { //TODO Crouton.makeText(this, "This is not currently supported.", Style.INFO).show(); } else if (preference.getKey().equals("resetusername")) { Util.getPreferences(this).edit().putString("username", "").commit(); Util.getPreferences(this).edit().putBoolean("hasLoggedInUsername", false).commit(); } return false; }
From source file:com.aengbee.android.leanback.presenter.GridItemPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { TextView view = new TextView(parent.getContext()); Resources res = parent.getResources(); int width = res.getDimensionPixelSize(R.dimen.grid_item_width); int height = res.getDimensionPixelSize(R.dimen.grid_item_height); view.setLayoutParams(new ViewGroup.LayoutParams(width, height)); view.setFocusable(true);/*from ww w .j av a 2 s.c o m*/ view.setFocusableInTouchMode(true); view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.default_background)); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER); return new ViewHolder(view); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java
public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from ww w . j a v a 2 s . co m*/ // TODO: hack to show object history in app feeds SignedObj appState = getAppStateForChildFeed(context, obj); if (appState != null) { mAppStateObj.render(context, frame, obj, allowInteractions); return; } else { String appName = content.optString(PACKAGE_NAME); if (appName.contains(".")) { // TODO: look up label. appName = appName.substring(appName.lastIndexOf(".") + 1); } String text = "Welcome to " + appName + "!"; TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } }