Java Code Examples for android.widget.TextView.getTextColors()

The following are Jave code examples for showing how to use getTextColors() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: android-instant-apps   File: DetailSharedElementEnterCallback.java   View Source Code Vote up 6 votes
@Override
public void onSharedElementStart(List<String> sharedElementNames,
                                 List<View> sharedElements,
                                 List<View> sharedElementSnapshots) {
    TextView author = getAuthor();
    targetTextSize = author.getTextSize();
    targetTextColors = author.getTextColors();
    targetPadding = new Rect(author.getPaddingLeft(),
            author.getPaddingTop(),
            author.getPaddingRight(),
            author.getPaddingBottom());
    if (IntentUtil.hasAll(intent,
            IntentUtil.TEXT_COLOR, IntentUtil.FONT_SIZE, IntentUtil.PADDING)) {
        author.setTextColor(intent.getIntExtra(IntentUtil.TEXT_COLOR, Color.BLACK));
        float textSize = intent.getFloatExtra(IntentUtil.FONT_SIZE, targetTextSize);
        author.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        Rect padding = intent.getParcelableExtra(IntentUtil.PADDING);
        author.setPadding(padding.left, padding.top, padding.right, padding.bottom);
    }
}
 
Example 2
Project: airgram   File: NumberPicker.java   View Source Code Vote up 4 votes
private void init() {
    mSolidColor = 0;
    mSelectionDivider = getResources().getDrawable(R.drawable.numberpicker_selection_divider);

    mSelectionDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT, getResources().getDisplayMetrics());
    mSelectionDividersDistance = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDERS_DISTANCE, getResources().getDisplayMetrics());

    mMinHeight = SIZE_UNSPECIFIED;

    mMaxHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, getResources().getDisplayMetrics());
    if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) {
        throw new IllegalArgumentException("minHeight > maxHeight");
    }

    mMinWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, getResources().getDisplayMetrics());

    mMaxWidth = SIZE_UNSPECIFIED;
    if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) {
        throw new IllegalArgumentException("minWidth > maxWidth");
    }

    mComputeMaxWidth = (mMaxWidth == SIZE_UNSPECIFIED);

    mVirtualButtonPressedDrawable = getResources().getDrawable(R.drawable.item_background_holo_light);

    mPressedStateHelper = new PressedStateHelper();

    setWillNotDraw(false);

    mInputText = new TextView(getContext());
    addView(mInputText);
    mInputText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mInputText.setGravity(Gravity.CENTER);
    mInputText.setSingleLine(true);
    mInputText.setBackgroundResource(0);
    mInputText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mTextSize = (int) mInputText.getTextSize();

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(mTextSize);
    paint.setTypeface(mInputText.getTypeface());
    ColorStateList colors = mInputText.getTextColors();
    int color = colors.getColorForState(ENABLED_STATE_SET, Color.WHITE);
    paint.setColor(color);
    mSelectorWheelPaint = paint;

    mFlingScroller = new Scroller(getContext(), null, true);
    mAdjustScroller = new Scroller(getContext(), new DecelerateInterpolator(2.5f));

    updateInputTextView();
}
 
Example 3
Project: PlusGram   File: NumberPicker.java   View Source Code Vote up 4 votes
private void init() {
    mSolidColor = 0;
    mSelectionDivider = getResources().getDrawable(R.drawable.numberpicker_selection_divider);

    mSelectionDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT, getResources().getDisplayMetrics());
    mSelectionDividersDistance = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDERS_DISTANCE, getResources().getDisplayMetrics());

    mMinHeight = SIZE_UNSPECIFIED;

    mMaxHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, getResources().getDisplayMetrics());
    if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) {
        throw new IllegalArgumentException("minHeight > maxHeight");
    }

    mMinWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, getResources().getDisplayMetrics());

    mMaxWidth = SIZE_UNSPECIFIED;
    if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) {
        throw new IllegalArgumentException("minWidth > maxWidth");
    }

    mComputeMaxWidth = (mMaxWidth == SIZE_UNSPECIFIED);

    mVirtualButtonPressedDrawable = getResources().getDrawable(R.drawable.item_background_holo_light);

    mPressedStateHelper = new PressedStateHelper();

    setWillNotDraw(false);

    mInputText = new TextView(getContext());
    addView(mInputText);
    mInputText.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mInputText.setGravity(Gravity.CENTER);
    mInputText.setSingleLine(true);
    mInputText.setBackgroundResource(0);
    mInputText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mTextSize = (int) mInputText.getTextSize();

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(mTextSize);
    paint.setTypeface(mInputText.getTypeface());
    ColorStateList colors = mInputText.getTextColors();
    int color = colors.getColorForState(ENABLED_STATE_SET, Color.WHITE);
    paint.setColor(color);
    mSelectorWheelPaint = paint;

    mFlingScroller = new Scroller(getContext(), null, true);
    mAdjustScroller = new Scroller(getContext(), new DecelerateInterpolator(2.5f));

    updateInputTextView();
}
 
Example 4
Project: custode   File: SummaryActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_summary);
    overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);

    summaryTextView = (TextView) findViewById(R.id.summary_text_view);
    summaryTextViewDefaultColor = summaryTextView.getTextColors();
    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    contactsLinearLayout = (LinearLayout) findViewById(R.id.contacts_linear_layout);
    shutdownButton = (FloatingActionButton) findViewById(R.id.shutdown_button);
    shutdownButton.setOnClickListener(this);

    int flags = WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
            | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
    getWindow().addFlags(flags);

    // TODO: Sostituisci con BitmapDescriptorFactory.fromResource(R.drawable.ic_message) quando https://code.google.com/p/gmaps-api-issues/issues/detail?id=9011 sarĂ  corretto
    Drawable vectorDrawable = ContextCompat.getDrawable(this, R.drawable.ic_message);
    int w = vectorDrawable.getIntrinsicWidth();
    int h = vectorDrawable.getIntrinsicHeight();
    vectorDrawable.setBounds(0, 0, w, h);
    Bitmap bm = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bm);
    vectorDrawable.draw(canvas);
    mapMarkerBitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bm);
    // :ODOT

    MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment);
    mapFragment.getMapAsync(this);

    smsUpdateReceiver = new SmsUpdateReceiver();
    registerReceiver(smsUpdateReceiver, new IntentFilter("android.provider.Telephony.SMS_RECEIVED"));

    sentSmsStatusReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            int contactIndex = intent.getIntExtra(CONTACT_INDEX_EXTRA, -1);
            if (contactIndex < 0 || contactIndex >= favoriteContacts.size())
                return;

            boolean smsDelivered = intent.getAction().equals(SMS_STATUS_DELIVERED_ACTION);
            RoundedContactBadge contactBadge = (RoundedContactBadge) contactsLinearLayout.getChildAt(contactIndex);
            if (smsDelivered)
                contactBadge.setContactStatus(RoundedContactBadge.ContactStatus.DELIVERED);
            else {
                boolean smsSent = getResultCode() == Activity.RESULT_OK;
                contactBadge.setContactStatus(smsSent ? RoundedContactBadge.ContactStatus.SENT : RoundedContactBadge.ContactStatus.ERROR);
            }
        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(SMS_STATUS_SENT_ACTION);
    filter.addAction(SMS_STATUS_DELIVERED_ACTION);
    registerReceiver(sentSmsStatusReceiver, filter);

    loadContactsIfNeeded();
    if (savedInstanceState == null)
        alertAllContacts();
}
 
Example 5
Project: SetupWizardLibCompat   File: GlifLayout.java   View Source Code Vote up 4 votes
public ColorStateList getHeaderColor() {
    final TextView titleView = getHeaderTextView();
    return titleView != null ? titleView.getTextColors() : null;
}