Example usage for android.widget TextView setSingleLine

List of usage examples for android.widget TextView setSingleLine

Introduction

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

Prototype

public void setSingleLine() 

Source Link

Document

Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.

Usage

From source file:com.example.guxiuzhong.pagerslidingtab_lib.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);/*  w  w  w.j  ava  2  s.  c  o m*/
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    TextView tab2 = new TextView(getContext());
    tab2.setText(title);
    tab2.setGravity(Gravity.CENTER);
    tab2.setSingleLine();

    addTab(position, tab, tab2);
}

From source file:com.hybunion.member.view.PagerSlidingTabStrip.java

private void addTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setWidth(screenWidth / tabCount);// 
    tab.setText(title);//from   www .  j a v  a 2s.  co  m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}

From source file:com.yibairun.ui.components.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    //layout/*from  w  w w .  ja  v a 2  s.c  o  m*/
    RelativeLayout tabLayout = new RelativeLayout(getContext());
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tabLayout.setLayoutParams(layoutParams);

    RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    //tab
    TextView tab = new TextView(getContext());
    tab.setId(100 + position);
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tabLayout.addView(tab, textParams);

    //???
    RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId());
    viewParams.addRule(RelativeLayout.CENTER_VERTICAL);
    View view = new View(getContext());
    ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    view.setLayoutParams(vParams);
    tabLayout.addView(view, viewParams);

    BadgeView badgeView = new BadgeView(getContext(), view);
    badgeView.setTextSize(10);
    badgeView.setGravity(Gravity.CENTER);
    badgeView.setBadgePosition(BadgeView.POSITION_TOP_LEFT);
    badgeView.setTag(BAGE_TAG);

    addTab(position, tabLayout);

}

From source file:com.ranger.bmaterials.view.PagerSlidingTabStrip.java

private void addTextTab(final int position, final String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);// w  ww .ja v a2s. com
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (clickListener != null)
                clickListener.onClick(position, title);

            pager.setCurrentItem(position, false);

            currentPosition = position;
            currentPositionOffset = 0;
            scrollToChild(position, 0);
            invalidate();

        }
    });

    tabsContainer.addView(tab);

}

From source file:com.itheima.googlemarket.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    if (position == 0) {
        tab.setSelected(true); // ?1tab
    }//from ww w  .j a  v a  2  s  .com

    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    addTab(position, tab);
}

From source file:com.zxly.o2o.view.MPagerSlidingTab.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setPadding(DesityUtil.dp2px(getContext(), 6), 0, DesityUtil.dp2px(getContext(), 6), 0);
    tab.setText(title);//from  www  .jav a2s .c  om
    tab.setSingleLine();
    tab.setTextColor(tabTextColor);
    tab.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    addTab(position, tab);

}

From source file:com.huahan.hhbaseutils.view.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);/*from   w  w w  .  ja v a  2 s  .  c  om*/
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    if (isSingleLine) {
        tab.setSingleLine();
    }

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}

From source file:com.sqkj.widget.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setBackgroundResource(tabBackgroundResId);
    Log.d("textTab", "currentPosition=" + currentPosition + " position=" + position);
    tab.setText(title);// w w w  .j  av a2 s  . com
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    addTab(position, tab);
}

From source file:com.witmoon.xmb.ui.widget.PagerSlidingTabStrip.java

private void addTextIconTab(final int position, String title, int resId) {

    if (resId == TitleIconTabProvider.NONE_ICON) {
        addTextTab(position, title);/*from   ww  w. j  av  a  2 s . c  om*/
        return;
    }

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    ImageView icon = new ImageView(getContext());

    if (position == 1) {
        icon.setImageResource(icoColor1);
    } else {
        icon.setImageResource(selectedIcoColor);
    }

    LinearLayout linearLayout = new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(icon, defaultTabLayoutParams);
    linearLayout.addView(tab, defaultTabLayoutParams);

    addTab(position, linearLayout);
}

From source file:com.example.view.astuetz.PagerSlidingTabStrip.java

@SuppressLint("NewApi")
private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f));
    tab.setText(title);//from  w  ww.  j av a  2  s  .  c  o  m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    addTab(position, tab);
}