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:com.vonglasow.michael.satstat.MainActivity.java

protected static void showCellCdma(CellTowerCdma cell) {
    TableRow row = new TableRow(rilCdmaCells.getContext());
    row.setWeightSum(26);//from ww  w  .  jav a 2  s.  co  m

    TextView newType = new TextView(rilCdmaCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilCdmaCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilCdmaCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newSid = new TextView(rilCdmaCells.getContext());
    newSid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 6));
    newSid.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newSid.setText(formatCellData(rilCdmaCells.getContext(), null, cell.getSid()));
    row.addView(newSid);

    TextView newNid = new TextView(rilCdmaCells.getContext());
    newNid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newNid.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newNid.setText(formatCellData(rilCdmaCells.getContext(), null, cell.getNid()));
    row.addView(newNid);

    TextView newBsid = new TextView(rilCdmaCells.getContext());
    newBsid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newBsid.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newBsid.setText(formatCellData(rilCdmaCells.getContext(), null, cell.getBsid()));
    row.addView(newBsid);

    TextView newDbm = new TextView(rilCdmaCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilCdmaCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

    rilCdmaCells.addView(row,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}

From source file:com.vonglasow.michael.satstat.MainActivity.java

protected static void showCellGsm(CellTowerGsm cell) {
    TableRow row = new TableRow(rilCells.getContext());
    row.setWeightSum(29);/*  w  w  w . j  av  a  2  s  .c  o  m*/

    TextView newType = new TextView(rilCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newMcc = new TextView(rilCells.getContext());
    newMcc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMcc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newMcc.setText(formatCellData(rilCells.getContext(), "%03d", cell.getMcc()));
    row.addView(newMcc);

    TextView newMnc = new TextView(rilCells.getContext());
    newMnc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMnc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newMnc.setText(formatCellData(rilCells.getContext(), "%02d", cell.getMnc()));
    row.addView(newMnc);

    TextView newLac = new TextView(rilCells.getContext());
    newLac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newLac.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newLac.setText(formatCellData(rilCells.getContext(), null, cell.getLac()));
    row.addView(newLac);

    TextView newCid = new TextView(rilCells.getContext());
    newCid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newCid.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newCid.setText(formatCellData(rilCells.getContext(), null, cell.getCid()));
    row.addView(newCid);

    TextView newPsc = new TextView(rilCells.getContext());
    newPsc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newPsc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newPsc.setText(formatCellData(rilCells.getContext(), null, cell.getPsc()));
    row.addView(newPsc);

    TextView newDbm = new TextView(rilCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

    rilCells.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}

From source file:com.vonglasow.michael.satstat.MainActivity.java

protected static void showCellLte(CellTowerLte cell) {
    TableRow row = new TableRow(rilLteCells.getContext());
    row.setWeightSum(29);//w  w w .  j  av a  2s. com

    TextView newType = new TextView(rilLteCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilLteCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilLteCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newMcc = new TextView(rilLteCells.getContext());
    newMcc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMcc.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newMcc.setText(formatCellData(rilLteCells.getContext(), "%03d", cell.getMcc()));
    row.addView(newMcc);

    TextView newMnc = new TextView(rilLteCells.getContext());
    newMnc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMnc.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newMnc.setText(formatCellData(rilLteCells.getContext(), "%02d", cell.getMnc()));
    row.addView(newMnc);

    TextView newTac = new TextView(rilLteCells.getContext());
    newTac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newTac.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newTac.setText(formatCellData(rilLteCells.getContext(), null, cell.getTac()));
    row.addView(newTac);

    TextView newCi = new TextView(rilLteCells.getContext());
    newCi.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newCi.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newCi.setText(formatCellData(rilLteCells.getContext(), null, cell.getCi()));
    row.addView(newCi);

    TextView newPci = new TextView(rilLteCells.getContext());
    newPci.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newPci.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newPci.setText(formatCellData(rilLteCells.getContext(), null, cell.getPci()));
    row.addView(newPci);

    TextView newDbm = new TextView(rilLteCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilLteCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

    rilLteCells.addView(row,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}

From source file:io.doist.datetimepicker.time.RadialTimePickerView.java

private void drawDebug(Canvas canvas) {
    // Draw outer numbers circle
    final float outerRadius = mCircleRadius[HOURS] * mNumbersRadiusMultiplier[HOURS];
    canvas.drawCircle(mXCenter, mYCenter, outerRadius, mPaintDebug);

    // Draw inner numbers circle
    final float innerRadius = mCircleRadius[HOURS] * mNumbersRadiusMultiplier[HOURS_INNER];
    canvas.drawCircle(mXCenter, mYCenter, innerRadius, mPaintDebug);

    // Draw outer background circle
    canvas.drawCircle(mXCenter, mYCenter, mCircleRadius[HOURS], mPaintDebug);

    // Draw outer rectangle for circles
    float left = mXCenter - outerRadius;
    float top = mYCenter - outerRadius;
    float right = mXCenter + outerRadius;
    float bottom = mYCenter + outerRadius;
    canvas.drawRect(left, top, right, bottom, mPaintDebug);

    // Draw outer rectangle for background
    left = mXCenter - mCircleRadius[HOURS];
    top = mYCenter - mCircleRadius[HOURS];
    right = mXCenter + mCircleRadius[HOURS];
    bottom = mYCenter + mCircleRadius[HOURS];
    canvas.drawRect(left, top, right, bottom, mPaintDebug);

    // Draw outer view rectangle
    canvas.drawRect(0, 0, getWidth(), getHeight(), mPaintDebug);

    // Draw selected time
    final String selected = String.format("%02d:%02d", getCurrentHour(), getCurrentMinute());

    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    TextView tv = new TextView(getContext());
    tv.setLayoutParams(lp);
    tv.setText(selected);//w  w w.ja  v a2 s.c  om
    tv.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    Paint paint = tv.getPaint();
    paint.setColor(DEBUG_TEXT_COLOR);

    final int width = tv.getMeasuredWidth();

    float height = paint.descent() - paint.ascent();
    float x = mXCenter - width / 2;
    float y = mYCenter + 1.5f * height;

    canvas.drawText(selected, x, y, paint);
}

From source file:com.consumer.widget.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;/*from w ww  .  j a va  2  s  .c o m*/
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setTextColor(getResources().getColor(R.color.TabPager));
        LinearLayout.LayoutParams param = null;

        /** KULDIP:  To Increase the First Tabs Size compare to others.*/
        if (i == 0) {
            param = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f);
        } else {
            param = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.2f);
        }
        tabTitleView.setBackgroundDrawable(getResources().getDrawable(R.drawable.selector_blue_tab));
        tabTitleView.setLayoutParams(param);

        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java

/** initAddDestButton()
 * adds the Driving Through button/*www.  j a v  a2  s .  co m*/
 */
protected void initAddDestButton() {

    //Adds/enables the FrameLayout
    AddDestFrameLayout = new FrameLayout(this);
    AddDestFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT, 80));
    AddDestFrameLayout.setEnabled(true);

    //Fills the Image Icon
    ImageView destAddIcon = new ImageView(this);
    FrameLayout.LayoutParams lliDestIcon = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lliDestIcon.setMargins(dipToPx(10), 0, 0, dipToPx(2));
    destAddIcon.setLayoutParams(lliDestIcon);
    destAddIcon.setPadding(0, dipToPx(5), 0, 0);
    destAddIcon.setImageResource(R.drawable.google_marker_thumb_mini_through);

    //Adds the imageicon to the framelayout/enables it 
    AddDestFrameLayout.addView(destAddIcon);

    //Fills/sets the text
    TextView destAddText = new TextView(this);
    FrameLayout.LayoutParams lliDest = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lliDest.setMargins(0, dipToPx(5), 0, 0);
    destAddText.setLayoutParams(lliDest);
    destAddText.setPadding(dipToPx(40), dipToPx(6), 0, 0);
    destAddText.setTextSize(15);
    destAddText.setText(R.string.mapViewAcField);

    //Adds the text to the framelayout
    AddDestFrameLayout.addView(destAddText);

    //Adds the framelayout to the linearlayout (in the scrollview)
    sclLayout = (LinearLayout) findViewById(R.id.sclLayout);
    sclLayout.addView(AddDestFrameLayout, sclLayout.getChildCount());

    final Button button = ((Button) findViewById(R.id.btnChooseRoute));

    //Adds a clicklistener to the frameLayout
    AddDestFrameLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //Adds a new destination field
            initDestFrameLayout();

            //Moves the button to the bottom
            setLayoutParams();

            if (checkFields() == false) {
                button.setEnabled(false);
                button.setText("Show on map");
            } else {
                mapView.getOverlays().clear();
                createMap();
            }
        }

    });
}

From source file:com.borax12.materialdaterangepicker.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.range_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.mdtp_hour_picker_description);
    mSelectHours = res.getString(R.string.mdtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.mdtp_select_minutes);
    mSelectedColor = res.getColor(R.color.mdtp_white);
    mUnselectedColor = res.getColor(R.color.mdtp_accent_color_focused);

    tabHost = (TabHost) view.findViewById(R.id.tabHost);
    tabHost.findViewById(R.id.tabHost);//from  w ww  . java2 s  . c  om
    tabHost.setup();
    TabHost.TabSpec startDatePage = tabHost.newTabSpec("start");
    startDatePage.setContent(R.id.start_date_group);
    startDatePage.setIndicator("FROM");

    TabHost.TabSpec endDatePage = tabHost.newTabSpec("end");
    endDatePage.setContent(R.id.end_date_group);
    endDatePage.setIndicator("TO");

    tabHost.addTab(startDatePage);
    tabHost.addTab(endDatePage);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourViewEnd = (TextView) view.findViewById(R.id.hours_end);
    mHourViewEnd.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mHourSpaceViewEnd = (TextView) view.findViewById(R.id.hour_space_end);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteSpaceViewEnd = (TextView) view.findViewById(R.id.minutes_space_end);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mMinuteViewEnd = (TextView) view.findViewById(R.id.minutes_end);
    mMinuteViewEnd.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    mAmPmTextViewEnd = (TextView) view.findViewById(R.id.ampm_label_end);
    mAmPmTextViewEnd.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(), this, mInitialHourOfDay, mInitialMinute, mIs24HourMode);

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

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

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mHourViewEnd.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();
        }
    });
    mMinuteViewEnd.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mOkButton = (Button) view.findViewById(R.id.ok);
    mOkButton.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(),
                        mTimePickerEnd.getHours(), mTimePickerEnd.getMinutes());
            }
            dismiss();
        }
    });
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(getDialog().getContext(), "Roboto-Medium"));

    mCancelButton = (Button) view.findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(getDialog().getContext(), "Roboto-Medium"));
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    mAmPmHitspaceEnd = view.findViewById(R.id.ampm_hitspace_end);

    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);
        mAmPmTextViewEnd.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);
        TextView separatorViewEnd = (TextView) view.findViewById(R.id.separator_end);
        separatorView.setLayoutParams(paramsSeparator);
        separatorViewEnd.setLayoutParams(paramsSeparator);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        mAmPmTextViewEnd.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);
            }
        });
        mAmPmHitspaceEnd.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                tryVibrate();
                int amOrPm = mTimePickerEnd.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                updateAmPmDisplay(amOrPm);
                mTimePickerEnd.setAmOrPm(amOrPm);
            }
        });
    }

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

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

    // Set the title (if any)
    TextView timePickerHeader = (TextView) view.findViewById(R.id.time_picker_header);
    TextView timePickerHeaderEnd = (TextView) view.findViewById(R.id.time_picker_header_end);
    if (!mTitle.isEmpty()) {
        timePickerHeader.setVisibility(TextView.VISIBLE);
        timePickerHeader.setText(mTitle);
        timePickerHeaderEnd.setVisibility(TextView.VISIBLE);
        timePickerHeaderEnd.setText(mTitle);
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark);
    mTimePickerEnd.setTheme(getActivity().getApplicationContext(), mThemeDark);

    //If an accent color has not been set manually, try and get it from the context
    if (mAccentColor == -1) {
        int accentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
        if (accentColor != -1) {
            mAccentColor = accentColor;
        }
    }
    if (mAccentColor != -1) {
        mTimePicker.setAccentColor(mAccentColor);
        mTimePickerEnd.setAccentColor(mAccentColor);
        mOkButton.setTextColor(mAccentColor);
    } else {
        int circleBackground = res.getColor(R.color.mdtp_circle_background);
        int backgroundColor = res.getColor(R.color.mdtp_background_color);
        int darkBackgroundColor = res.getColor(R.color.mdtp_light_gray);
        int lightGray = res.getColor(R.color.mdtp_light_gray);

        mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
        mTimePickerEnd.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
        view.findViewById(R.id.time_picker_dialog)
                .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    }

    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            if (tabId == "start") {
                setCurrentItemShowing(mTimePicker.getCurrentItemShowing(), true, false, true);
                setHour(mTimePicker.getHours(), false);
                setMinute(mTimePicker.getMinutes());
                updateAmPmDisplay(mTimePicker.getIsCurrentlyAmOrPm());
            } else {
                setCurrentItemShowing(mTimePickerEnd.getCurrentItemShowing(), true, false, true);
                setHour(mTimePickerEnd.getHours(), false);
                setMinute(mTimePickerEnd.getMinutes());
                updateAmPmDisplay(mTimePickerEnd.getIsCurrentlyAmOrPm());
            }
        }
    });
    return view;
}

From source file:com.cdms.codrive.Common.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from   w ww. j  a  v  a2  s . com*/
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    //        textView.setTextColor(R.color.red);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    final PagerAdapter adapter = mViewPager.getAdapter();
    LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT, 1.0f / adapter.getCount());
    textView.setLayoutParams(param);

    return textView;
}

From source file:com.cookbeans.boredapp.ui.view.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from  w  w w .ja  va2 s.c om
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(Color.WHITE);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    //        textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setTypeface(Typeface.DEFAULT);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0,
            ViewGroup.LayoutParams.WRAP_CONTENT, 1f);
    textView.setLayoutParams(layoutParams);

    return textView;
}

From source file:com.consumer.widget.SlidingTabLayoutSpend.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;/*w w  w.j  a v a2  s  .  co  m*/
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setTextColor(getResources().getColor(R.color.TabPager));
        LinearLayout.LayoutParams param = null;

        /** KULDIP:  To Increase the First Tabs Size compare to others.*/
        // if(i ==0){
        param = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f);
        /*}else{
           param = new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT, 1.2f);
        }*/
        //123  tabTitleView.setBackgroundDrawable(getResources().getDrawable(R.drawable.selector_blue_tab));
        tabTitleView.setLayoutParams(param);

        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
        // mTabStrip.setSelectedIndicatorColors(R.color.White);
    }
}