Example usage for android.widget TextView setLayoutParams

List of usage examples for android.widget TextView setLayoutParams

Introduction

In this page you can find the example usage for android.widget TextView setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:jp.seesaa.android.datetimepicker.time.TimePickerDialog.java

public View createView(LayoutInflater inflater, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dtp_time_picker_dialog, null);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    Resources res = getResources();
    mHourPickerDescription = res.getString(R.string.dtp_hour_picker_description);
    mSelectHours = res.getString(R.string.dtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.dtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.dtp_select_minutes);
    mSelectedColor = res.getColor(mThemeDark ? R.color.dtp_red : R.color.dtp_blue);
    mUnselectedColor = res.getColor(mThemeDark ? R.color.dtp_white : R.color.dtp_numbers_text_color);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];/*w w  w. j av a 2s. c  om*/
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute,
            mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });

    //        mDoneButton = (TextView) view.findViewById(R.id.done_button);
    //        mDoneButton.setOnClickListener(new OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                if (mInKbMode && isTypedTimeFullyLegal()) {
    //                    finishKbMode(false);
    //                } else {
    //                    tryVibrate();
    //                }
    //                if (mCallback != null) {
    //                    mCallback.onTimeSet(mTimePicker,
    //                            mTimePicker.getHours(), mTimePicker.getMinutes());
    //                }
    //                dismiss();
    //            }
    //        });
    //        mDoneButton.setOnKeyListener(keyboardListener);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);

        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                updateAmPmDisplay(amOrPm);
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    mAllowAutoAdvance = true;
    setHour(mInitialHourOfDay, true);
    setMinute(mInitialMinute);

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.dtp_time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.dtp_deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<Integer>();
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark);
    // Prepare some colors to use.
    int white = res.getColor(R.color.dtp_white);
    int circleBackground = res.getColor(R.color.dtp_circle_background);
    int line = res.getColor(R.color.dtp_line_background);
    int timeDisplay = res.getColor(R.color.dtp_numbers_text_color);
    ColorStateList doneTextColor = res.getColorStateList(R.color.dtp_done_text_color);
    int doneBackground = R.drawable.dtp_done_background_color;

    int darkGray = res.getColor(R.color.dtp_dark_gray);
    int lightGray = res.getColor(R.color.dtp_light_gray);
    int darkLine = res.getColor(R.color.dtp_line_dark);
    ColorStateList darkDoneTextColor = res.getColorStateList(R.color.dtp_done_text_color_dark);
    int darkDoneBackground = R.drawable.dtp_done_background_color_dark;

    // Set the colors for each view based on the theme.
    view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white);
    view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white);
    ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay);
    ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay);
    //        view.findViewById(R.id.line).setBackgroundColor(mThemeDark ? darkLine : line);
    //        mDoneButton.setTextColor(mThemeDark ? darkDoneTextColor : doneTextColor);
    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    //        mDoneButton.setBackgroundResource(mThemeDark ? darkDoneBackground : doneBackground);
    return view;
}

From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java

/**
 * Create or recreate the limiter breadcrumbs.
 *///from  w  ww.j a  va 2 s  .  com
public void updateLimiterViews() {
    mLimiterViews.removeAllViews();

    Limiter limiterData = mPagerAdapter.getCurrentLimiter();
    if (limiterData != null) {
        String[] limiter = limiterData.names;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 5;
        for (int i = 0; i != limiter.length; ++i) {
            PaintDrawable background = new PaintDrawable(Color.GRAY);
            background.setCornerRadius(5);

            TextView view = new TextView(this);
            view.setSingleLine();
            view.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            view.setText(limiter[i] + " | X");
            view.setTextColor(Color.WHITE);
            view.setBackgroundDrawable(background);
            view.setLayoutParams(params);
            view.setPadding(5, 2, 5, 2);
            view.setTag(i);
            view.setOnClickListener(this);
            mLimiterViews.addView(view);
        }

        mLimiterScroller.setVisibility(View.VISIBLE);
    } else {
        mLimiterScroller.setVisibility(View.GONE);
    }
}

From source file:com.doomonafireball.betterpickers.radialtimepicker.RadialTimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }/*from w  ww  .  j  a  v  a  2s. co m*/

    View view = inflater.inflate(R.layout.radial_time_picker_dialog, null);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    Resources res = getResources();
    mHourPickerDescription = res.getString(R.string.hour_picker_description);
    mSelectHours = res.getString(R.string.select_hours);
    mMinutePickerDescription = res.getString(R.string.minute_picker_description);
    mSelectMinutes = res.getString(R.string.select_minutes);
    mSelectedColor = res.getColor(mThemeDark ? R.color.red : R.color.blue);
    mUnselectedColor = res.getColor(mThemeDark ? R.color.white : R.color.numbers_text_color);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute,
            mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mDoneButton = (TextView) view.findViewById(R.id.done_button);
    if (mDoneText != null) {
        mDoneButton.setText(mDoneText);
    }
    mDoneButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            if (mCallback != null) {
                mCallback.onTimeSet(RadialTimePickerDialog.this, mTimePicker.getHours(),
                        mTimePicker.getMinutes());
            }
            dismiss();
        }
    });
    mDoneButton.setOnKeyListener(keyboardListener);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);

        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                updateAmPmDisplay(amOrPm);
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    mAllowAutoAdvance = true;
    setHour(mInitialHourOfDay, true);
    setMinute(mInitialMinute);

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<Integer>();
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark);
    // Prepare some colors to use.
    int white = res.getColor(R.color.white);
    int circleBackground = res.getColor(R.color.circle_background);
    int line = res.getColor(R.color.line_background);
    int timeDisplay = res.getColor(R.color.numbers_text_color);
    ColorStateList doneTextColor = res.getColorStateList(R.color.done_text_color);
    int doneBackground = R.drawable.done_background_color;

    int darkGray = res.getColor(R.color.dark_gray);
    int lightGray = res.getColor(R.color.light_gray);
    int darkLine = res.getColor(R.color.line_dark);
    ColorStateList darkDoneTextColor = res.getColorStateList(R.color.done_text_color_dark);
    int darkDoneBackground = R.drawable.done_background_color_dark;

    // Set the colors for each view based on the theme.
    view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white);
    view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white);
    ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay);
    ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay);
    view.findViewById(R.id.line).setBackgroundColor(mThemeDark ? darkLine : line);
    mDoneButton.setTextColor(mThemeDark ? darkDoneTextColor : doneTextColor);
    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    mDoneButton.setBackgroundResource(mThemeDark ? darkDoneBackground : doneBackground);
    return view;
}

From source file:com.github.irshulx.Components.InputExtensions.java

private TextView getNewTextView(CharSequence text) {
    final TextView textView = new TextView(
            new ContextThemeWrapper(this.editorCore.getContext(), R.style.WysiwygEditText));
    addEditableStyling(textView);//  ww  w. j a v a  2 s. c o  m
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    textView.setLayoutParams(params);
    if (!TextUtils.isEmpty(text)) {
        Spanned __ = Html.fromHtml(text.toString());
        CharSequence toReplace = noTrailingwhiteLines(__);
        textView.setText(toReplace);
        Linkify.addLinks(textView, Linkify.ALL);
    }

    if (this.lineSpacing != -1) {
        setLineSpacing(textView, this.lineSpacing);
    }
    return textView;
}

From source file:com.learnncode.mediachooser.activity.HomeFragmentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_home_media_chooser);

    headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar);
    headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar);
    headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView);
    headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView);
    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);

    mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent);
    headerBarBack.setOnClickListener(clickListener);
    headerBarCamera.setOnClickListener(clickListener);
    headerBarDone.setOnClickListener(clickListener);

    if (!MediaChooserConstants.showCameraVideo) {
        headerBarCamera.setVisibility(View.GONE);
    }//from  ww w  .ja  va2  s . c  o  m

    if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) {

        if (getIntent().getBooleanExtra("image", false)) {
            headerBarTitle.setText(getResources().getString(R.string.image));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));

            headerBarCamera.setTag(getResources().getString(R.string.image));

            Bundle bundle = new Bundle();
            bundle.putString("name", getIntent().getStringExtra("name"));
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab1")
                            .setIndicator(getResources().getString(R.string.images_tab) + "     "),
                    ImageFragment.class, bundle);

        } else {
            headerBarTitle.setText(getResources().getString(R.string.video));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
            headerBarCamera.setTag(getResources().getString(R.string.video));

            Bundle bundle = new Bundle();
            bundle.putString("name", getIntent().getStringExtra("name"));
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab2")
                            .setIndicator(getResources().getString(R.string.videos_tab) + "      "),
                    VideoFragment.class, bundle);
        }
    } else {

        if (MediaChooserConstants.showVideo) {
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab2")
                            .setIndicator(getResources().getString(R.string.videos_tab) + "      "),
                    VideoFragment.class, null);
        }

        if (MediaChooserConstants.showImage) {
            headerBarTitle.setText(getResources().getString(R.string.image));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));
            headerBarCamera.setTag(getResources().getString(R.string.image));

            mTabHost.addTab(
                    mTabHost.newTabSpec("tab1")
                            .setIndicator(getResources().getString(R.string.images_tab) + "      "),
                    ImageFragment.class, null);
        }

        if (MediaChooserConstants.showVideo) {
            headerBarTitle.setText(getResources().getString(R.string.video));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
            headerBarCamera.setTag(getResources().getString(R.string.video));
        }
    }

    for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {

        TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
        if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) {

            RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) textView
                    .getLayoutParams();
            params.addRule(RelativeLayout.CENTER_HORIZONTAL);
            params.addRule(RelativeLayout.CENTER_VERTICAL);
            params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
            params.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
            textView.setLayoutParams(params);

        } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) {
            LinearLayout.LayoutParams params = (android.widget.LinearLayout.LayoutParams) textView
                    .getLayoutParams();
            params.gravity = Gravity.CENTER;
            textView.setLayoutParams(params);
        }
        textView.setTextColor(getResources().getColor(R.color.tabs_title_color));
        textView.setTextSize(convertDipToPixels(10));

    }

    if ((mTabHost.getTabWidget().getChildAt(0) != null)) {
        ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                .setTextColor(Color.WHITE);
    }

    if ((mTabHost.getTabWidget().getChildAt(1) != null)) {
        ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
    }

    mTabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {

            android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
            ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1");
            VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2");
            android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

            if (tabId.equalsIgnoreCase("tab1")) {

                headerBarTitle.setText(getResources().getString(R.string.image));
                setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));
                headerBarCamera.setTag(getResources().getString(R.string.image));

                if (imageFragment != null) {

                    if (videoFragment != null) {
                        fragmentTransaction.hide(videoFragment);
                    }
                    fragmentTransaction.show(imageFragment);
                }
                ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                        .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
                ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                        .setTextColor(Color.WHITE);

            } else {
                headerBarTitle.setText(getResources().getString(R.string.video));
                setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
                headerBarCamera.setTag(getResources().getString(R.string.video));

                if (videoFragment != null) {

                    if (imageFragment != null) {
                        fragmentTransaction.hide(imageFragment);
                    }

                    fragmentTransaction.show(videoFragment);
                    if (videoFragment.getAdapter() != null) {
                        videoFragment.getAdapter().notifyDataSetChanged();
                    }
                }
                ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                        .setTextColor(Color.WHITE);
                ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                        .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
            }

            fragmentTransaction.commit();
        }
    });

    RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) headerBarCamera
            .getLayoutParams();
    params.height = convertDipToPixels(40);
    params.width = convertDipToPixels(40);
    headerBarCamera.setLayoutParams(params);
    headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE);
    headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15),
            convertDipToPixels(15));

}

From source file:com.yktx.check.widget.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    TextView tab = null;
    if (position == 3) {//?
        view2 = LayoutInflater.from(getContext()).inflate(R.layout.pagerslidingtabstip_text, null);
        text2 = (TextView) view2.findViewById(R.id.text);
        image2 = (ImageView) view2.findViewById(R.id.image);
        //         badgeView = new BadgeView(getContext(), text2);
        addTab(position, view2);/*  w w  w .ja  va 2  s .  c om*/
    } else {
        tab = new TextView(getContext());
        tab.setText(title);
        tab.setSingleLine();
        tab.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        tab.setGravity(Gravity.CENTER);
        addTab(position, tab);
    }

}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

/**
 * Create or recreate the limiter breadcrumbs.
 *///from w  ww .  jav  a 2 s .  c o  m
public void updateLimiterViews() {
    mLimiterViews.removeAllViews();

    Limiter limiterData = mPagerAdapter.getCurrentLimiter();
    if (limiterData != null) {
        String[] limiter = limiterData.names;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 5;
        for (int i = 0; i != limiter.length; ++i) {
            int color = (i + 1 == limiter.length ? 0xFFA0A0A0 : 0xFFC0C0C0);
            PaintDrawable background = new PaintDrawable(color);
            background.setCornerRadius(0);

            TextView view = new TextView(this);
            view.setSingleLine();
            view.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            view.setText(limiter[i]);
            view.setTextColor(Color.WHITE);
            view.setBackgroundDrawable(background);
            view.setLayoutParams(params);
            view.setPadding(14, 6, 14, 6);
            view.setTag(i);
            view.setOnClickListener(this);
            mLimiterViews.addView(view);
        }

        mLimiterScroller.setVisibility(View.VISIBLE);
    } else {
        mLimiterScroller.setVisibility(View.GONE);
    }
}

From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }/* ww  w.  j a  v a2s  .c  om*/

    View view = inflater.inflate(R.layout.radial_time_picker_dialog, null);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    Resources res = getResources();
    TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId,
            R.styleable.BetterPickersRadialTimePickerDialog);

    mHourPickerDescription = res.getString(R.string.hour_picker_description);
    mSelectHours = res.getString(R.string.select_hours);
    mMinutePickerDescription = res.getString(R.string.minute_picker_description);
    mSelectMinutes = res.getString(R.string.select_minutes);
    mSelectedColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpAccentColor,
            R.color.bpBlue);
    mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainTextColor,
            R.color.numbers_text_color);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute,
            mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mDoneButton = (TextView) view.findViewById(R.id.done_button);
    if (mDoneText != null) {
        mDoneButton.setText(mDoneText);
    }
    mDoneButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            if (mCallback != null) {
                mCallback.onTimeSet(RadialTimePickerDialog.this, mTimePicker.getHours(),
                        mTimePicker.getMinutes());
            }
            dismiss();
        }
    });
    mDoneButton.setOnKeyListener(keyboardListener);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);

        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                updateAmPmDisplay(amOrPm);
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    mAllowAutoAdvance = true;
    setHour(mInitialHourOfDay, true);
    setMinute(mInitialMinute);

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<Integer>();
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mTimePicker.setTheme(themeColors);

    // Prepare some colors to use.
    int mainColor1 = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainColor1,
            R.color.bpWhite);
    int mainColor2 = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainColor2,
            R.color.circle_background);
    int lineColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpLineColor,
            R.color.bpLine_background);
    int mainTextColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainTextColor,
            R.color.numbers_text_color);
    ColorStateList doneTextColor = themeColors
            .getColorStateList(R.styleable.BetterPickersRadialTimePickerDialog_bpDoneTextColor);
    int doneBackground = themeColors.getResourceId(
            R.styleable.BetterPickersRadialTimePickerDialog_bpDoneBackgroundColor,
            R.drawable.done_background_color);

    // Set the colors for each view based on the theme.
    view.findViewById(R.id.time_display_background).setBackgroundColor(mainColor1);
    view.findViewById(R.id.time_display).setBackgroundColor(mainColor1);
    ((TextView) view.findViewById(R.id.separator)).setTextColor(mainTextColor);
    ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mainTextColor);
    view.findViewById(R.id.line).setBackgroundColor(lineColor);
    mDoneButton.setTextColor(doneTextColor);
    mTimePicker.setBackgroundColor(mainColor2);
    mDoneButton.setBackgroundResource(doneBackground);
    return view;
}

From source file:com.example.pickerclickcar.time.TimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.time_picker_dialog, null);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    Resources res = getResources();
    mHourPickerDescription = res.getString(R.string.hour_picker_description);
    mSelectHours = res.getString(R.string.select_hours);
    mMinutePickerDescription = res.getString(R.string.minute_picker_description);
    mSelectMinutes = res.getString(R.string.select_minutes);
    mSelectedColor = res.getColor(mThemeDark ? R.color.red : R.color.white);
    mUnselectedColor = res.getColor(mThemeDark ? android.R.color.white : R.color.blue_focused);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];//from w w w.j av  a  2s .com
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);

    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute,
            mIs24HourMode, mMinHour, mMaxHour, mMinMinute, mMaxMinute);
    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mDoneButton = (TextView) view.findViewById(R.id.done_button);
    mDoneButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            if (mCallback != null) {
                mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes());
            }
            dismiss();
        }
    });
    mCancelButton = (Button) view.findViewById(R.id.cancel_button);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    mDoneButton.setOnKeyListener(keyboardListener);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);

        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                updateAmPmDisplay(amOrPm);
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    mAllowAutoAdvance = true;
    setHour(mInitialHourOfDay, true);
    setMinute(mInitialMinute);

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<Integer>();
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark);
    // Prepare some colors to use.
    int white = res.getColor(R.color.mainblue);
    int sep = res.getColor(R.color.blue_focused);
    int circleBackground = res.getColor(R.color.white);
    int line = res.getColor(R.color.mainblue);
    int timeDisplay = res.getColor(R.color.numbers_text_color);
    ColorStateList doneTextColor = res.getColorStateList(R.color.done_text_color);
    int doneBackground = R.drawable.done_background_color;

    int darkGray = res.getColor(R.color.dark_gray);
    int lightGray = res.getColor(R.color.circle_background);
    int darkLine = res.getColor(R.color.mainblue);
    ColorStateList darkDoneTextColor = res.getColorStateList(R.color.mainblue);
    int darkDoneBackground = R.drawable.done_background_color_dark;

    // Set the colors for each view based on the theme.
    view.findViewById(R.id.time_display_background).setBackgroundColor(white);
    view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white);
    ((TextView) view.findViewById(R.id.separator)).setTextColor(sep);
    ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay);
    view.findViewById(R.id.line).setBackgroundColor(line);
    mDoneButton.setTextColor(white);
    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    mDoneButton.setBackgroundColor(circleBackground);
    mCancelButton.setBackgroundColor(circleBackground);
    return view;
}

From source file:com.philliphsu.hybridtimepicker.HybridTimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.hybrid_time_picker_dialog, null);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    Resources res = getResources();
    mHourPickerDescription = res.getString(R.string.hour_picker_description);
    mSelectHours = res.getString(R.string.select_hours);
    mMinutePickerDescription = res.getString(R.string.minute_picker_description);
    mSelectMinutes = res.getString(R.string.select_minutes);
    // TODO: Rename variable to mAccentColor
    mSelectedColor = //res.getColor(mThemeDark? R.color.red : R.color.blue);
            Utils.getAccentColorFromThemeIfAvailable(getActivity());
    mUnselectedColor = res.getColor(mThemeDark ? android.R.color.white : R.color.numbers_text_color);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];//from  ww  w.j a v a 2s  .co  m
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    mGridPicker = (GridPickerLayout) view.findViewById(R.id.time_picker);
    mGridPicker.setOnValueSelectedListener(this);
    // TODO: Adapt to my GridPickerLayout
    //        mTimePicker.setOnKeyListener(keyboardListener);
    mGridPicker.initialize(getActivity(), /*mHapticFeedbackController,*/ this, mInitialHourOfDay,
            mInitialMinute, mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mGridPicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mCancelButton = (TextView) view.findViewById(R.id.cancel_button);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            // TODO: Do we need to fire a OnDialogCancel event?
            dismiss();
        }
    });
    mCancelButton.setOnKeyListener(keyboardListener);

    mDoneButton = (TextView) view.findViewById(R.id.done_button);
    mDoneButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            if (mCallback != null) {
                mCallback.onTimeSet(mGridPicker, mGridPicker.getHours(), mGridPicker.getMinutes());
            }
            dismiss();
        }
    });
    mDoneButton.setOnKeyListener(keyboardListener);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);

        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                tryVibrate();
                int amOrPm = mGridPicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                updateAmPmDisplay(amOrPm);
                mGridPicker.setAmOrPm(amOrPm);
            }
        });
    }

    mAllowAutoAdvance = true;
    setHour(mInitialHourOfDay, true);
    setMinute(mInitialMinute);

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<Integer>();
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mGridPicker.setTheme(getActivity().getApplicationContext(), mThemeDark);
    // Prepare some colors to use.
    int white = res.getColor(android.R.color.white);
    //        int circleBackground = res.getColor(R.color.circle_background);
    //        int line = res.getColor(R.color.line_background);
    int timeDisplay = res.getColor(R.color.numbers_text_color);
    // We'll just use an actual color instead of a ColorStateList for the dialog buttons since
    // I don't see why we would ever need to disable them.
    //        ColorStateList dialogButtonsTextColor = res.getColorStateList(R.color.dialog_buttons_text_color);
    int doneBackground = R.drawable.done_background_color;

    int darkGray = res.getColor(R.color.dark_gray);
    //        int lightGray = res.getColor(R.color.light_gray);
    //        int darkLine = res.getColor(R.color.line_dark);
    // TODO: We don't have an accent color variant for the dark theme, so leave it off for now.
    //        ColorStateList darkDialogButtonsTextColor = res.getColorStateList(R.color.dialog_buttons_text_color_dark);
    int darkDoneBackground = R.drawable.done_background_color_dark;

    // Set the colors for each view based on the theme.
    view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white);
    view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white);
    ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay);
    ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay);
    //        view.findViewById(R.id.line).setBackgroundColor(mThemeDark? darkLine : line);
    mDoneButton.setTextColor(mSelectedColor); // accent color
    mCancelButton.setTextColor(mSelectedColor); // accent color
    mGridPicker.setBackgroundColor(mThemeDark ? darkGray : white);
    ((LinearLayout) view.findViewById(R.id.dialog_buttons)).setBackgroundColor(mThemeDark ? darkGray : white);
    return view;
}