List of usage examples for android.widget TextView setTextSize
@android.view.RemotableViewMethod public void setTextSize(float size)
From source file:com.apps.gator.DisplayTranslationActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final ServiceUtility serviceUtility = new ServiceUtility(); // retrieve the shared preferences file which has stored the radio // buttons state information. final SharedPreferences prefs = this.getSharedPreferences(MainActivity.PREFS_NAME, Context.MODE_PRIVATE); // Get the message from the intent final Intent intent = getIntent(); final String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); // Create the text view final TextView textView = new TextView(this); textView.setTextSize(20); // Logic to determine if the user selected to translate from English to // Malayalam or Malayalam to English. if (prefs.getBoolean(MainActivity.RADIO_BUTTON_MALAYALAM, false)) { final Translator translator = Translator.Factory.create(TranslateType.ENGLISH_TO_MALAYALAM); final TranslatorResponse response = translator.translate(message); switch (response.getLookupResponseMap().size()) { case 0:/* w ww . j a va2 s . com*/ textView.setText(response.getLookupResponse()); break; default: final StringBuilder stringBuilder = serviceUtility.buildIndividualLookupResponse(response); textView.setText(stringBuilder); break; } } else if (prefs.getBoolean(MainActivity.RADIO_BUTTON_ENGLISH, false)) { final Translator translator = Translator.Factory.create(TranslateType.MALAYALM_TO_ENGLISH); final TranslatorResponse response = translator.translate(message); switch (response.getLookupResponseMap().size()) { case 0: textView.setText(response.getLookupResponse()); break; default: final StringBuilder stringBuilder = serviceUtility.buildIndividualLookupResponse(response); textView.setText(stringBuilder); break; } } // Fall back logic to make sure the User experience is not // affected. else { textView.setText( "Please select if you would like to translate to Malayalam or English on the Home View"); } // Set the text view as the activity layout setContentView(textView); }
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);/*from w w w . j a v 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:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
/** * Called from FindActivity.onActivityResult(). Used to * update the Find's View, specifically the date, lat, long, * and alarm icon fields.//w w w .j ava2 s. c o m * * @param context, the calling Activity * @param find, the current Find * @param view, the FindActivity's content view * @param intent, the Intent that is passed to the menu activity */ public void onActivityResultCallback(Context context, Find find, View view, Intent intent) { Log.i(TAG, "onActivityResultCallbac"); // Intent is NOT null, meaning it includes reminder // date and location information set by the user if (intent != null) { Bundle bundle = intent.getExtras(); // Get date, longitude, and latitude String date = bundle.getString(Find.TIME); Double longitude = bundle.getDouble(Find.LONGITUDE); Double latitude = bundle.getDouble(Find.LATITUDE); TextView tv = (TextView) view.findViewById(R.id.isAdhocTextView); Integer is_adhoc = bundle.getInt(Find.IS_ADHOC); Log.i(TAG, "is_adhoc = " + is_adhoc); if (tv != null) { Log.i(TAG, "Setting isAdhocTextView to " + is_adhoc); tv.setText("" + is_adhoc); } // Display user specified longitude and latitude tv = (TextView) view.findViewById(R.id.longitudeValueTextView); tv.setText(String.valueOf(longitude)); tv = (TextView) view.findViewById(R.id.latitudeValueTextView); tv.setText(String.valueOf(latitude)); // Remove the old row that displays time and replace it // with a new row that include an alarm clock icon to // visually indicate this find has a reminder attached ViewGroup parent = (ViewGroup) view.findViewById(R.id.timeValueTextView).getParent(); parent.removeAllViews(); ImageView alarmIcon = new ImageView(context); alarmIcon.setImageResource(R.drawable.reminder_alarm); TableRow.LayoutParams lp1 = new TableRow.LayoutParams(30, 30); lp1.setMargins(0, 6, 80, 0); parent.addView(alarmIcon, lp1); TextView mCloneTimeTV = new TextView(context); mCloneTimeTV.setId(R.id.timeValueTextView); mCloneTimeTV.setText(date); mCloneTimeTV.setTextSize(12); TextView mTimeTV = (TextView) view.findViewById(R.id.timeValueTextView); mTimeTV = mCloneTimeTV; TableRow.LayoutParams lp2 = new TableRow.LayoutParams(); lp2.setMargins(6, 6, 0, 0); parent.addView(mTimeTV, lp2); } }
From source file:com.uzmap.pkg.uzmodules.UISearchBar.SearchBarActivity.java
@SuppressWarnings("deprecation") private void initData() { DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); mPref = getSharedPreferences("text", Context.MODE_PRIVATE); String text = mPref.getString("text", ""); if (!TextUtils.isEmpty(text)) { mEditText.setText(text);/*from w w w .ja v a2 s. c om*/ mEditText.setSelection(text.length()); } mNavigationLayout.setBackgroundColor(config.navBgColor); if (TextUtils.isEmpty(config.searchBoxBgImg)) { BitmapDrawable bitmapDrawable = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), UZResourcesIDFinder.getResDrawableID("mo_searchbar_bg"))); mRelativeLayout.setBackgroundDrawable(bitmapDrawable); } else { BitmapDrawable bitmapDrawable = new BitmapDrawable(generateBitmap(config.searchBoxBgImg)); mRelativeLayout.setBackgroundDrawable(bitmapDrawable); } if (config.cancel_bg_bitmap != null) { mTextView.setBackgroundDrawable(new BitmapDrawable(config.cancel_bg_bitmap)); } else { mTextView.setBackgroundColor(config.cancel_bg_color); } mTextView.setTextSize(config.cancel_size); mTextView.setTextColor(config.cancal_color); LayoutParams params = new LayoutParams(UZUtility.dipToPix(config.searchBoxWidth), UZUtility.dipToPix(config.searchBoxHeight)); params.setMargins(UZUtility.dipToPix(10), 0, 0, 0); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mEditText.setLayoutParams(params); WindowManager wm = this.getWindowManager(); int width = wm.getDefaultDisplay().getWidth(); double realWidth = width * 0.80; LayoutParams layoutParams = new LayoutParams((int) realWidth, UZUtility.dipToPix(config.searchBoxHeight)); layoutParams.setMargins(UZUtility.dipToPix(5), 0, 0, 0); layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); layoutParams.topMargin = UZUtility.dipToPix(8); layoutParams.bottomMargin = UZUtility.dipToPix(8); mRelativeLayout.setLayoutParams(layoutParams); double cancelRealWidth = width * 0.15; int space = (width - (int) realWidth - (int) cancelRealWidth - UZUtility.dipToPix(5)) / 2; LayoutParams cancalTxtParam = new LayoutParams((int) cancelRealWidth, UZUtility.dipToPix(config.searchBoxHeight)); cancalTxtParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); cancalTxtParam.addRule(RelativeLayout.CENTER_VERTICAL); cancalTxtParam.rightMargin = space; cancalTxtParam.leftMargin = space; mTextView.setLayoutParams(cancalTxtParam); mListView.setBackgroundColor(config.list_bg_color); listSize = config.list_size; mCleanTextColor = config.clear_font_color; mCleanTextSize = config.clear_font_size; recordCount = config.historyCount; /** * add clean list item */ int relativeLayoutCleanId = UZResourcesIDFinder.getResLayoutID("mo_searchbar_clean_item"); relativeLayoutClean = (LinearLayout) View.inflate(getApplicationContext(), relativeLayoutCleanId, null); int tv_cleanId = UZResourcesIDFinder.getResIdID("tv_clean"); mCleanTV = (TextView) relativeLayoutClean.findViewById(tv_cleanId); mCleanTV.setTextSize(mCleanTextSize); mCleanTV.setTextColor(mCleanTextColor); mCleanTV.setText(config.clearText); relativeLayoutClean .setBackgroundDrawable(addStateDrawable(config.clear_bg_color, config.clear_active_bg_color)); list.clear(); list.add(relativeLayoutClean); mPref = getSharedPreferences("history" + config.database, Context.MODE_PRIVATE); editor = mPref.edit(); trimHistroyList(config.historyCount); @SuppressWarnings("unchecked") Map<String, String> map = (Map<String, String>) mPref.getAll(); if (map != null) { if (map.size() != 0) { for (int i = 1; i <= map.size(); i++) { int listview_item = UZResourcesIDFinder.getResLayoutID("mo_searchbar_listview_item"); LinearLayout linearLayout = (LinearLayout) View.inflate(SearchBarActivity.this, listview_item, null); int tv_listId = UZResourcesIDFinder.getResIdID("tv_listview"); TextView tv = (TextView) linearLayout.findViewById(tv_listId); tv.setTextSize(listSize); tv.setTextColor(config.list_color); linearLayout.setBackgroundDrawable( addStateDrawable(config.list_bg_color, config.list_item_active_bg_color)); int itemBorderLineId = UZResourcesIDFinder.getResIdID("item_border_line"); linearLayout.findViewById(itemBorderLineId).setBackgroundColor(config.list_border_color); for (Entry<String, String> iterable_element : map.entrySet()) { String key = iterable_element.getKey(); if ((i + "").equals(key)) { tv.setText(iterable_element.getValue()); } } list.addFirst(linearLayout); } id = map.size(); } } adapter = new MyAdapter(); mListView.setAdapter(adapter); }
From source file:com.example.drugsformarinemammals.Dose_Information.java
public TextView createTitleTextView() { TextView title_textview = new TextView(this); title_textview.setTextSize(20); title_textview.setTextColor(getResources().getColor(R.color.darkGray)); title_textview.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); return title_textview; }
From source file:org.quantumbadger.redreader.activities.InboxListingActivity.java
private void makeFirstRequest(final Context context) { final RedditAccount user = RedditAccountManager.getInstance(context).getDefaultAccount(); final CacheManager cm = CacheManager.getInstance(context); final URI url; if (!isModmail) { url = Constants.Reddit.getUri("/message/inbox.json?mark=true&limit=100"); } else {/*from w w w .j a v a 2s .c o m*/ url = Constants.Reddit.getUri("/message/moderator.json?limit=100"); } // TODO parameterise limit request = new CacheRequest(url, user, null, Constants.Priority.API_INBOX_LIST, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.INBOX_LIST, true, true, true, context) { @Override protected void onDownloadNecessary() { } @Override protected void onDownloadStarted() { } @Override protected void onCallbackException(final Throwable t) { request = null; BugReportActivity.handleGlobalError(context, t); } @Override protected void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { request = null; if (loadingView != null) loadingView.setDone(R.string.download_failed); final RRError error = General.getGeneralErrorForFailure(context, type, t, status, url.toString()); AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { public void run() { notifications.addView(new ErrorView(InboxListingActivity.this, error)); } }); if (t != null) t.printStackTrace(); } @Override protected void onProgress(final boolean authorizationInProgress, final long bytesRead, final long totalBytes) { } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, final long timestamp, final UUID session, final boolean fromCache, final String mimetype) { request = null; } @Override public void onJsonParseStarted(final JsonValue value, final long timestamp, final UUID session, final boolean fromCache) { if (loadingView != null) loadingView.setIndeterminate(R.string.download_downloading); // TODO pref (currently 10 mins) // TODO xml if (fromCache && RRTime.since(timestamp) > 10 * 60 * 1000) { AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { public void run() { final TextView cacheNotif = new TextView(context); cacheNotif.setText(context.getString(R.string.listing_cached) + RRTime.formatDateTime(timestamp, context)); final int paddingPx = General.dpToPixels(context, 6); final int sidePaddingPx = General.dpToPixels(context, 10); cacheNotif.setPadding(sidePaddingPx, paddingPx, sidePaddingPx, paddingPx); cacheNotif.setTextSize(13f); notifications.addView(cacheNotif); adapter.notifyDataSetChanged(); } }); } // TODO {"error": 403} is received for unauthorized subreddits try { final JsonBufferedObject root = value.asObject(); final JsonBufferedObject data = root.getObject("data"); final JsonBufferedArray children = data.getArray("children"); for (JsonValue child : children) { final RedditThing thing = child.asObject(RedditThing.class); switch (thing.getKind()) { case COMMENT: final RedditPreparedComment comment = new RedditPreparedComment( InboxListingActivity.this, thing.asComment(), timestamp, false, null, user, headerItems); itemHandler.sendMessage(General.handlerMessage(0, comment)); break; case MESSAGE: final RedditPreparedMessage message = new RedditPreparedMessage( InboxListingActivity.this, thing.asMessage(), timestamp); itemHandler.sendMessage(General.handlerMessage(0, message)); if (message.src.replies != null && message.src.replies.getType() == JsonValue.Type.OBJECT) { final JsonBufferedArray replies = message.src.replies.asObject().getObject("data") .getArray("children"); for (JsonValue childMsgValue : replies) { final RedditMessage childMsgRaw = childMsgValue.asObject(RedditThing.class) .asMessage(); final RedditPreparedMessage childMsg = new RedditPreparedMessage( InboxListingActivity.this, childMsgRaw, timestamp); itemHandler.sendMessage(General.handlerMessage(0, childMsg)); } } break; default: throw new RuntimeException("Unknown item in list."); } } } catch (Throwable t) { notifyFailure(RequestFailureType.PARSE, t, null, "Parse failure"); return; } if (loadingView != null) loadingView.setDone(R.string.download_done); } }; cm.makeRequest(request); }
From source file:com.example.drugsformarinemammals.Dose_Information.java
private void displayMessage(String messageTitle, String message) { AlertDialog.Builder myalert = new AlertDialog.Builder(this); TextView title = new TextView(this); title.setTypeface(Typeface.SANS_SERIF); title.setTextSize(20); title.setTextColor(getResources().getColor(R.color.blue)); title.setPadding(8, 8, 8, 8);/*from w w w. ja v a 2 s. com*/ title.setText("Synchronization"); title.setGravity(Gravity.CENTER_VERTICAL); LinearLayout layout = new LinearLayout(this); TextView text = new TextView(this); text.setTypeface(Typeface.SANS_SERIF); text.setTextSize(20); text.setPadding(10, 10, 10, 10); text.setText(message); layout.addView(text); myalert.setView(layout); myalert.setCustomTitle(title); myalert.setCancelable(true); myalert.show(); }
From source file:com.example.drugsformarinemammals.Dose_Information.java
public TextView createInformationTextView() { TextView information_textview = new TextView(this); information_textview.setTextColor(Color.BLACK); information_textview.setTextSize(16); information_textview.setTypeface(Typeface.SANS_SERIF); return information_textview; }
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
private void displayArtistInfo_bk(JSONObject j) throws JSONException { if (imageLoader == null) imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) imageLoader.init(config);// w ww .jav a 2s.co m Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString()); JSONObject j_artist_info = j.getJSONObject("artist"); tArtistName.setText(j_artist_info.getString("name")); final JSONObject urls = j_artist_info.optJSONObject("urls"); final JSONArray videos = j_artist_info.optJSONArray("video"); final JSONArray images = j_artist_info.optJSONArray("images"); final String fm_image = j.optString("fm_image"); final JSONArray available_images = new JSONArray(); ArrayList<String> image_urls = new ArrayList<String>(); if (fm_image != null) { image_urls.add(fm_image); } Log.i("musicInfo", images.toString()); if (images != null) { for (int i = 0; i < images.length(); i++) { JSONObject image = images.getJSONObject(i); int width = image.optInt("width", 0); int height = image.optInt("height", 0); String url = image.optString("url", ""); Log.i("musicInfo", i + ": " + url); if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) { //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) { image_urls.add(url); Log.i("musicInfo", "Selected: " + url); //available_images.put(image); } } int random = (int) (Math.random() * image_urls.size()); final String f_url = image_urls.get(random); //int random = (int) (Math.random() * available_images.length()); //final JSONObject fImage = available_images.length()>0?available_images.getJSONObject(random > images.length() ? 0 : random):images.getJSONObject(0); Log.i("musicInfo", "Total image#=" + available_images.length() + " Selected image#=" + random + " " + f_url); imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { lLinkList.removeAllViews(); //String attr = fImage.optJSONObject("license").optString("attribution"); //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr)); if (urls != null) { String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url", "twitter_url" }; for (int i = 0; i < jsonName.length; i++) { if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) { Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i])); TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); switch (jsonName[i]) { case "official_url": tv.setText("HOME."); break; case "wikipedia_url": tv.setText("WIKI."); break; case "mb_url": tv.setText("Music Brainz."); break; case "lastfm_url": tv.setText("Last FM."); break; case "twitter_url": tv.setText("Twitter."); break; } try { tv.setTag(urls.getString(jsonName[i])); } catch (JSONException e) { e.printStackTrace(); } tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse((String) v.getTag())); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Toast.makeText(getApplicationContext(), "Open the Link...", Toast.LENGTH_SHORT).show(); //finish(); } }); lLinkList.addView(tv); } } } else { TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setText("Sorry, No Link Here..."); lLinkList.addView(tv); } if (videos != null) { jVideoArray = videos; mAdapter = new StaggeredViewAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, generateImageData(videos)); //if (mData == null) { mData = generateImageData(videos); //} //mAdapter.clear(); for (JSONObject data : mData) { mAdapter.add(data); } mGridView.setAdapter(mAdapter); } else { } adjBottomColor(((ImageView) view).getDrawable()); } @Override public void onLoadingCancelled(String imageUri, View view) { } }); } }
From source file:com.box.myview.MyTopSnackBar.TSnackbar.java
/** * Sets the text color of the action specified in *//*from w ww .j a v a 2 s.c o m*/ @NonNull public TSnackbar setMessageTextSize(int size) { final TextView tv = mView.getMessageView(); tv.setTextSize(size); return this; }