List of usage examples for android.widget TextView getTextColors
public final ColorStateList getTextColors()
From source file:com.bt.download.android.gui.util.UIUtils.java
/** * Android devices with SDK below target=11 do not support textView.setAlpha(). * This is a work around. //from www . j a v a2 s .c om * @param v - the text view * @param alpha - a value from 0 to 255. (0=transparent, 255=fully visible) */ public static void setTextViewAlpha(TextView v, int alpha) { v.setTextColor(v.getTextColors().withAlpha(alpha)); v.setHintTextColor(v.getHintTextColors().withAlpha(alpha)); v.setLinkTextColor(v.getLinkTextColors().withAlpha(alpha)); Drawable[] compoundDrawables = v.getCompoundDrawables(); for (int i = 0; i < compoundDrawables.length; i++) { Drawable d = compoundDrawables[i]; if (d != null) { d.setAlpha(alpha); } } }
From source file:com.dmbstream.android.util.Util.java
private static void findNotificationTextColors(ViewGroup group, String title, String content) { for (int i = 0; i < group.getChildCount(); i++) { if (group.getChildAt(i) instanceof TextView) { TextView textView = (TextView) group.getChildAt(i); String text = textView.getText().toString(); if (title.equals(text)) { NOTIFICATION_TEXT_COLORS.setFirst(textView.getTextColors().getDefaultColor()); } else if (content.equals(text)) { NOTIFICATION_TEXT_COLORS.setSecond(textView.getTextColors().getDefaultColor()); }//from w w w . j a va2 s . c om } else if (group.getChildAt(i) instanceof ViewGroup) findNotificationTextColors((ViewGroup) group.getChildAt(i), title, content); } }
From source file:org.kei.android.phone.cellhistory.fragments.AreasFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Context context = getActivity().getApplicationContext(); /* UI *///w w w.j a v a 2 s . c om TextView dummy = new TextView(getActivity()); lvAreas = (ListView) getView().findViewById(R.id.lvAreas); lvAreas.setAdapter(new AreasArrayAdapter(dummy.getTextColors().getDefaultColor(), context, R.layout.view_area, new ArrayList<AreaInfo>())); CellHistoryApp app = CellHistoryApp.getApp(getActivity()); List<AreaInfo> areas = app.getSQL().getAreas(); app.getGlobalTowerInfo().lock(); try { app.getGlobalTowerInfo().getAreas().clear(); app.getGlobalTowerInfo().getAreas().addAll(areas); } finally { app.getGlobalTowerInfo().unlock(); } try { processUI(CellHistoryApp.getApp(getActivity()).getGlobalTowerInfo()); } catch (Throwable e) { Log.e(getClass().getSimpleName(), "Exception: " + e.getMessage(), e); } }
From source file:org.kei.android.phone.cellhistory.fragments.NeighboringFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Context context = getActivity().getApplicationContext(); /* UI *///from w w w . ja v a2 s . c o m TextView dummy = new TextView(getActivity()); lvNeighboring = (ListView) getView().findViewById(R.id.lvNeighboring); lvNeighboring.setAdapter(new NeighboringArrayAdapter(dummy.getTextColors().getDefaultColor(), context, R.layout.view_neighboring, new ArrayList<NeighboringInfo>())); try { processUI(CellHistoryApp.getApp(getActivity()).getGlobalTowerInfo()); } catch (Throwable e) { Log.e(getClass().getSimpleName(), "Exception: " + e.getMessage(), e); } }
From source file:org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter.java
@Override public View newView(Context context, Cursor cursor, ViewGroup parent) { View view = mInflater.inflate(R.layout.view_key_keys_item, null); if (mDefaultTextColor == null) { TextView keyId = (TextView) view.findViewById(R.id.keyId); mDefaultTextColor = keyId.getTextColors(); }//from w w w .j a v a2 s .c o m return view; }
From source file:com.csipsimple.ui.outgoingcall.OutgoingAccountsAdapter.java
@SuppressWarnings("deprecation") private void setRowViewAlpha(View v, float alpha) { if (Compatibility.isCompatible(11)) { // In honeycomb or upper case, use the new setAlpha method if (setAlphaMethod == null) { try { setAlphaMethod = View.class.getDeclaredMethod("setAlpha", float.class); } catch (NoSuchMethodException e) { // Ignore not found set alpha class. }//from w w w . j a v a 2s .c o m } if (setAlphaMethod != null) { UtilityWrapper.safelyInvokeMethod(setAlphaMethod, v, alpha); } } else { // Try to set alpha on each component TextView tv; tv = (TextView) v.findViewById(R.id.AccTextView); tv.setTextColor(tv.getTextColors().withAlpha((int) (255 * alpha))); tv = (TextView) v.findViewById(R.id.AccTextStatusView); tv.setTextColor(tv.getTextColors().withAlpha((int) (255 * alpha))); ImageView img = (ImageView) v.findViewById(R.id.wizard_icon); img.setAlpha((int) (255 * alpha)); } }
From source file:com.sip.pwc.sipphone.ui.outgoingcall.OutgoingAccountsAdapter.java
@SuppressWarnings("deprecation") private void setRowViewAlpha(View v, float alpha) { if (Compatibility.isCompatible(11)) { // In honeycomb or upper case, use the new setAlpha method if (setAlphaMethod == null) { try { setAlphaMethod = View.class.getDeclaredMethod("setAlpha", float.class); } catch (NoSuchMethodException e) { // Ignore not found set alpha class. }/*from www .j a va 2 s . c o m*/ } if (setAlphaMethod != null) { //UtilityWrapper.safelyInvokeMethod(setAlphaMethod, v, alpha); //change tqc try { setAlphaMethod.invoke(v, alpha); } catch (Exception e) { e.printStackTrace(); } } } else { // Try to set alpha on each component TextView tv; tv = (TextView) v.findViewById(R.id.AccTextView); tv.setTextColor(tv.getTextColors().withAlpha((int) (255 * alpha))); tv = (TextView) v.findViewById(R.id.AccTextStatusView); tv.setTextColor(tv.getTextColors().withAlpha((int) (255 * alpha))); ImageView img = (ImageView) v.findViewById(R.id.wizard_icon); img.setAlpha((int) (255 * alpha)); } }
From source file:org.catrobat.catroid.content.bricks.BroadcastBrick.java
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(R.id.brick_broadcast_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView textBroadcastLabel = (TextView) view.findViewById(R.id.brick_broadcast_label); textBroadcastLabel.setTextColor(textBroadcastLabel.getTextColors().withAlpha(alphaValue)); Spinner broadcastSpinner = (Spinner) view.findViewById(R.id.brick_broadcast_spinner); ColorStateList color = textBroadcastLabel.getTextColors().withAlpha(alphaValue); broadcastSpinner.getBackground().setAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color); }// w w w .j a v a 2 s. c o m this.alphaValue = alphaValue; } return view; }
From source file:net.pmarks.chromadoze.NoiseService.java
private void addButtonToNotification(Notification n) { // Create a new RV with a Stop button. RemoteViews rv = new RemoteViews(getPackageName(), R.layout.notification_with_stop_button); PendingIntent pendingIntent = PendingIntent.getService(this, 0, newStopIntent(this, R.string.stop_reason_notification), PendingIntent.FLAG_CANCEL_CURRENT); rv.setOnClickPendingIntent(R.id.stop_button, pendingIntent); // Pre-render the original RV, and copy some of the colors. final View inflated = n.contentView.apply(this, new FrameLayout(this)); final TextView titleText = findTextView(inflated, getString(R.string.app_name)); final TextView defaultText = findTextView(inflated, getString(R.string.notification_text)); rv.setInt(R.id.divider, "setBackgroundColor", defaultText.getTextColors().getDefaultColor()); rv.setInt(R.id.stop_button_square, "setBackgroundColor", titleText.getTextColors().getDefaultColor()); // Insert a copy of the original RV into the new one. rv.addView(R.id.notification_insert, n.contentView.clone()); // Splice everything back into the original's root view. int id = Resources.getSystem().getIdentifier("status_bar_latest_event_content", "id", "android"); n.contentView.removeAllViews(id);/*from ww w . j a v a 2 s.c o m*/ n.contentView.addView(id, rv); }
From source file:hku.fyp14017.blencode.content.bricks.BroadcastBrick.java
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(hku.fyp14017.blencode.R.id.brick_broadcast_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView textBroadcastLabel = (TextView) view .findViewById(hku.fyp14017.blencode.R.id.brick_broadcast_label); textBroadcastLabel.setTextColor(textBroadcastLabel.getTextColors().withAlpha(alphaValue)); Spinner broadcastSpinner = (Spinner) view .findViewById(hku.fyp14017.blencode.R.id.brick_broadcast_spinner); ColorStateList color = textBroadcastLabel.getTextColors().withAlpha(alphaValue); broadcastSpinner.getBackground().setAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color); }/* ww w . ja v a 2 s. c o m*/ this.alphaValue = (alphaValue); } return view; }