Java Code Examples for android.widget.LinearLayout.setLayoutParams()

The following are Jave code examples for showing how to use setLayoutParams() of the android.widget.LinearLayout 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: navigation-widgets   File: NavigationLayoutFactory.java   View Source Code Vote up 7 votes
@Override
public View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container) {
    LinearLayout parent = new LinearLayout(inflater.getContext());
    parent.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    parent.setOrientation(VERTICAL);

    View child = origin.produceLayout(inflater, parent);
    LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    if (includeBottomBar) {
        childParams.weight = 1;
    }

    if (includeToolbar) {
        inflater.inflate(R.layout.toolbar, parent);
    }
    parent.addView(child, childParams);
    if (includeBottomBar) {
        AHBottomNavigation bottomNavigation = new AHBottomNavigation(parent.getContext());
        bottomNavigation.setId(R.id.bottomNavigation);
        parent.addView(
                bottomNavigation,
                new LinearLayout.LayoutParams(MATCH_PARENT, (int) dp(parent.getContext(), 56)));
    }

    return parent;
}
 
Example 2
Project: HutHelper   File: AutoScrollViewPager.java   View Source Code Vote up 6 votes
public void initPointView(int size) {
    layout = new LinearLayout(context);
    for (int i = 0; i < size; i++) {
        ImageView imageView = new ImageView(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20, 20);
        params.leftMargin = 8;
        params.gravity = Gravity.CENTER;
        imageView.setLayoutParams(params);
        if (i == 0) {
            imageView.setBackgroundResource(R.drawable.ic_point_checked);
        } else {
            imageView.setBackgroundResource(R.drawable.ic_point_normal);
        }
        layout.addView(imageView);
    }
    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(ALIGN_PARENT_BOTTOM);
    layoutParams.addRule(CENTER_HORIZONTAL);

    layoutParams.setMargins(12, 20, 12, 20);
    layout.setLayoutParams(layoutParams);
    addView(layout);
}
 
Example 3
Project: TestChat   File: SwipeMenuView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int index) {
    LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight());
    params.weight = item.getWeight();
    LinearLayout parent = new LinearLayout(getContext());
    parent.setId(index);
    parent.setGravity(Gravity.CENTER);
    parent.setOrientation(VERTICAL);
    parent.setLayoutParams(params);
    ResCompat.setBackground(parent, item.getBackground());
    parent.setOnClickListener(mMenuClickListener);
    addView(parent);

    if (item.getImage() != null)
        parent.addView(createIcon(item));

    if (!TextUtils.isEmpty(item.getText()))
        parent.addView(createTitle(item));
}
 
Example 4
Project: MainCalendar   File: FilePicker.java   View Source Code Vote up 6 votes
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setBackgroundColor(Color.WHITE);
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    ListView listView = new ListView(activity);
    listView.setBackgroundColor(Color.WHITE);
    listView.setDivider(new ColorDrawable(0xFFDDDDDD));
    listView.setDividerHeight(1);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setSelector(R.color.itemSelected);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(this);
    rootLayout.addView(listView);
    return rootLayout;
}
 
Example 5
Project: CustomDialog   File: EnsureDialog.java   View Source Code Vote up 6 votes
/**
 * 构建
 *
 * @return
 */
public EnsureDialog builder() {
    final View view = LayoutInflater.from(context).inflate(R.layout.dialog_ensure_layout, null, false);
    LinearLayout mLinearDialog = ((LinearLayout) view.findViewById(R.id.linear_dialog));
    mLinearBottom = ((LinearLayout) view.findViewById(R.id.linear_bottom));

    mIvIcon = ((ImageView) view.findViewById(R.id.iv_icon));
    mTvTitle = ((TextView) view.findViewById(R.id.tv_title));
    mTvSubTitle = ((TextView) view.findViewById(R.id.tv_sub_title));
    mTvSure = ((TextView) view.findViewById(R.id.tv_sure));
    mTvOK = ((TextView) view.findViewById(R.id.tv_ok));
    mTvCancel = ((TextView) view.findViewById(R.id.tv_cancel));
    dialog.setContentView(view);
    mLinearDialog.setLayoutParams(new FrameLayout.LayoutParams(((int) (display.getWidth() * 0.80)), LinearLayout.LayoutParams.WRAP_CONTENT));
    dialogWindow.setGravity(Gravity.CENTER);
    return this;
}
 
Example 6
Project: PlusGram   File: PagerSlidingTabStrip.java   View Source Code Vote up 6 votes
public PagerSlidingTabStrip(Context context) {
    super(context);

    setFillViewport(true);
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    addView(tabsContainer);

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutHelper.MATCH_PARENT);
}
 
Example 7
Project: Building-Android-UIs-with-Custom-Views   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setLayoutParams(
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    OwnCustomView customView = new OwnCustomView(this);
    customView.setTopLeftColor(BRIGHT_RED);
    customView.setTopRightColor(BRIGHT_GREEN);
    customView.setBottomLeftColor(BRIGHT_YELLOW);
    customView.setBottomRightColor(BRIGHT_BLUE);
    linearLayout.addView(customView);

    setContentView(linearLayout);
}
 
Example 8
Project: Building-Android-UIs-with-Custom-Views   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setLayoutParams(
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    OwnCustomView customView = new OwnCustomView.Builder(this)
            .topLeftColor(BRIGHT_RED)
            .topRightColor(BRIGHT_GREEN)
            .bottomLeftColor(BRIGHT_YELLOW)
            .bottomRightColor(BRIGHT_BLUE)
            .build();

    linearLayout.addView(customView);

    setContentView(linearLayout);
}
 
Example 9
Project: Hotspot-master-devp   File: CustomAlertPPtDialog.java   View Source Code Vote up 5 votes
public CustomAlertPPtDialog builder() {
    view = LayoutInflater.from(context).inflate(R.layout.view_alertdialog, null);

    lLayout_bg = (LinearLayout) view.findViewById(R.id.layout_bg);
    txt_title = (TextView) view.findViewById(R.id.txt_title);
    txt_title.setVisibility(View.GONE);
    txt_msg = (TextView) view.findViewById(R.id.txt_msg);
    txt_msg.setVisibility(View.GONE);
    et_input = (EditText) view.findViewById(R.id.et_input);
    et_input.setVisibility(View.GONE);
    btn_neg = (Button) view.findViewById(R.id.btn_neg);
    btn_neg.setVisibility(View.GONE);
    btn_pos = (Button) view.findViewById(R.id.btn_pos);
    btn_pos.setVisibility(View.GONE);
    btn_mid = (Button) view.findViewById(R.id.btn_mid);
    btn_mid.setVisibility(View.GONE);
    line1 = (ImageView) view.findViewById(R.id.line1);
    line1.setVisibility(View.GONE);
    line2 = (ImageView) view.findViewById(R.id.line2);
    line2.setVisibility(View.GONE);

    dialog = new Dialog(context, R.style.AlertDialogStyle);
    dialog.setContentView(view);

    lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (
            display.getWidth() * 0.85), LayoutParams.WRAP_CONTENT));

    return this;
}
 
Example 10
Project: BestPracticeApp   File: DialogActivity.java   View Source Code Vote up 5 votes
public void createDialog() {
    setContentView(R.layout.dialog_bottom);
    show();
    Window window = getWindow();
    LinearLayout ll_content = (LinearLayout) window.findViewById(R.id.ll_content);
    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) ll_content.getLayoutParams();
    layoutParams.gravity = Gravity.BOTTOM;
    ll_content.setLayoutParams(layoutParams);


}
 
Example 11
Project: Building-Android-UIs-with-Custom-Views   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setLayoutParams(
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    OwnCustomView customView = new OwnCustomView(this);
    customView.setFillColor(BRIGHT_GREEN);
    linearLayout.addView(customView);

    setContentView(linearLayout);
}
 
Example 12
Project: TestChat   File: BaseDialog.java   View Source Code Vote up 5 votes
public BaseDialog setCheckBoxName(List<String> list) {
        if (middleLayout.getChildCount() > 0) {
                middleLayout.removeAllViews();
        }
        for (String title :
                list) {
                TextView textView = new TextView(getContext());
                textView.setGravity(Gravity.START);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                layoutParams.weight = 1;
                textView.setLayoutParams(layoutParams);
                textView.setText(title);
                final CheckBox checkBox = new CheckBox(getContext());
                checkBox.setGravity(Gravity.END);
                LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                checkBoxLayout.weight = 1;
                checkBox.setLayoutParams(checkBoxLayout);
                LinearLayout linearLayout = new LinearLayout(getContext());
                LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                linearLayout.setWeightSum(2);
                linearLayout.setLayoutParams(linearLayoutParam);
                linearLayout.addView(textView);
                linearLayout.addView(checkBox);
                middleLayout.addView(linearLayout);
        }
        return this;
}
 
Example 13
Project: cordova-plugin-navigation   File: NavigationActivity.java   View Source Code Vote up 5 votes
private void initView() {
    LinearLayout layout = new LinearLayout(this);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layout.setLayoutParams(layoutParams);

    AMapNaviView navigationView = new AMapNaviView(this);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layout.addView(navigationView, lp);
    this.navigationView = navigationView;
    setContentView(layout);
}
 
Example 14
Project: GitHub   File: BGARefreshLayout.java   View Source Code Vote up 5 votes
/**
 * 初始化整个头部控件
 */
private void initWholeHeaderView() {
    mWholeHeaderView = new LinearLayout(getContext());
    mWholeHeaderView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mWholeHeaderView.setOrientation(LinearLayout.VERTICAL);
    addView(mWholeHeaderView);
}
 
Example 15
Project: BoardView   File: BoardView.java   View Source Code Vote up 5 votes
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mRootLayout = new HorizontalScrollView(getContext());
    mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
    mParentLayout = new LinearLayout(getContext());
    mParentLayout.setOrientation(LinearLayout.HORIZONTAL);
    mScroller = new Scroller(mRootLayout.getContext(), new DecelerateInterpolator(1.2f));
    mParentLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    mRootLayout.addView(mParentLayout);
    addView(mRootLayout);
}
 
Example 16
Project: ywApplication   File: EditPage.java   View Source Code Vote up 5 votes
private LinearLayout getMainBody() {
	LinearLayout llMainBody = new LinearLayout(getContext());
	llMainBody.setOrientation(LinearLayout.VERTICAL);
	LayoutParams lpMain = new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpMain.weight = 1;
	int dp_4 = dipToPx(getContext(), 4);
	lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
	llMainBody.setLayoutParams(lpMain);

	LinearLayout llContent = new LinearLayout(getContext());
	LayoutParams lpContent = new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpContent.weight = 1;
	llMainBody.addView(llContent, lpContent);

	// share content editor
	etContent = new EditText(getContext());
	etContent.setGravity(Gravity.LEFT | Gravity.TOP);
	etContent.setBackgroundDrawable(null);
	etContent.setText(String.valueOf(shareParamMap.get("text")));
	etContent.addTextChangedListener(this);
	LayoutParams lpEt = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpEt.weight = 1;
	etContent.setLayoutParams(lpEt);
	llContent.addView(etContent);

	llContent.addView(getThumbView());
	llMainBody.addView(getBodyBottom());

	return llMainBody;
}
 
Example 17
Project: draggable-tree-itemview   File: TreeNode.java   View Source Code Vote up 4 votes
public TreeNode(Context context){
    isRoot = true;
    view = new LinearLayout(context);
    view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    ((LinearLayout)view).setOrientation(LinearLayout.VERTICAL);
}
 
Example 18
Project: YCWeather   File: WeatherView.java   View Source Code Vote up 4 votes
public void setList(final List<WeatherModel> list) {
    this.list = list;
    int screenWidth = getScreenWidth();
    int maxDay = getMaxDayTemp(list);
    int maxNight = getMaxNightTemp(list);
    int minDay = getMinDayTemp(list);
    int minNight = getMinNightTemp(list);
    int max = maxDay > maxNight ? maxDay : maxNight;
    int min = minDay < minNight ? minDay : minNight;
    removeAllViews();
    LinearLayout llRoot = new LinearLayout(getContext());
    llRoot.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    llRoot.setOrientation(LinearLayout.HORIZONTAL);
    for (int i = 0; i < list.size(); i++) {
        WeatherModel model = list.get(i);
        final WeatherItemView itemView = new WeatherItemView(getContext());
        itemView.setMaxTemp(max);
        itemView.setMinTemp(min);
        itemView.setDate(model.getDate());
        itemView.setWeek(model.getWeek());
        itemView.setDayTemp(model.getDayTemp());
        itemView.setDayWeather(model.getDayWeather());
        if (model.getDayPic() == 0) {
            if (model.getDayWeather() != null){
                itemView.setDayImg(WeatherUtil.getDayWeatherPic(model.getDayWeather()));
            }
        } else {
            itemView.setDayImg(model.getDayPic());
        }
        itemView.setNightWeather(model.getNightWeather());
        itemView.setNightTemp(model.getNightTemp());
        if (model.getNightPic() == 0) {
            if (model.getNightWeather() != null){
                itemView.setNightImg(WeatherUtil.getNightWeatherPic(model.getNightWeather()));
            }
        } else {
            itemView.setNightImg(model.getNightPic());
        }
        itemView.setWindOri(model.getWindOrientation());
        itemView.setWindLevel(model.getWindLevel());
        itemView.setAirLevel(model.getAirLevel());
        itemView.setLayoutParams(new LinearLayout.LayoutParams(screenWidth / columnNumber, ViewGroup.LayoutParams.WRAP_CONTENT));
        itemView.setClickable(true);
        final int finalI = i;
        itemView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (weatherItemClickListener != null) {
                    weatherItemClickListener.onItemClick(itemView, finalI, list.get(finalI));
                }
            }
        });
        llRoot.addView(itemView);
    }
    addView(llRoot);
    invalidate();
}
 
Example 19
Project: GitHub   File: BackVerifyDialogLayout.java   View Source Code Vote up 4 votes
/**验证返回对话框布局*/
public static LinearLayout create(Context context) {
	SizeHelper.prepare(context);

	LinearLayout root = new LinearLayout(context);
	ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
	root.setLayoutParams(params);
	root.setOrientation(LinearLayout.VERTICAL);

	TextView dialogHint = new TextView(context);
	dialogHint.setId(ResHelper.getIdRes(context, "tv_dialog_hint"));
	LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	hintParams.topMargin = SizeHelper.fromPxWidth(32);
	hintParams.bottomMargin = SizeHelper.fromPxWidth(32);
	dialogHint.setLayoutParams(hintParams);
	dialogHint.setPadding(SizeHelper.fromPxWidth(18), 0, SizeHelper.fromPxWidth(18), 0);
	dialogHint.setLineSpacing(SizeHelper.fromPxWidth(8), 1);
	int resid = ResHelper.getStringRes(context, "smssdk_make_sure_mobile_detail");
	dialogHint.setText(resid);
	dialogHint.setTextColor(0xffffffff);
	dialogHint.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(26));
	dialogHint.setGravity(Gravity.CENTER);
	root.addView(dialogHint);

	View line = new View(context);
	LinearLayout.LayoutParams lineParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
			SizeHelper.fromPxWidth(1));
	line.setLayoutParams(lineParams);
	line.setBackgroundColor(0xff737373);
	root.addView(line);

	LinearLayout wrapper = new LinearLayout(context);
	LinearLayout.LayoutParams wrapperParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	wrapper.setLayoutParams(wrapperParams);


	Button ok = new Button(context);
	ok.setId(ResHelper.getIdRes(context, "btn_dialog_ok"));
	LinearLayout.LayoutParams okParams = new LinearLayout.LayoutParams(0,SizeHelper.fromPxWidth(78),1);
	okParams.leftMargin = SizeHelper.fromPxWidth(3);
	ok.setLayoutParams(okParams);
	resid = ResHelper.getBitmapRes(context, "smssdk_dialog_btn_back");
	ok.setBackgroundResource(resid);
	int padding = SizeHelper.fromPxWidth(8);
	ok.setPadding(padding, padding, padding, padding);
	resid = ResHelper.getStringRes(context, "smssdk_ok");
	ok.setText(resid);
	ok.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	ok.setTextColor(0xffffffff);
	wrapper.addView(ok);

	View line2 = new View(context);
	LinearLayout.LayoutParams line2Params = new LinearLayout.LayoutParams(SizeHelper.fromPxWidth(1),
			LinearLayout.LayoutParams.MATCH_PARENT);
	line2.setLayoutParams(line2Params);
	line2.setBackgroundColor(0xff737373);
	wrapper.addView(line2);

	Button cancel = new Button(context);
	cancel.setId(ResHelper.getIdRes(context, "btn_dialog_cancel"));
	LinearLayout.LayoutParams cancelParams = new LinearLayout.LayoutParams(0,SizeHelper.fromPxWidth(78),1);
	cancelParams.rightMargin = SizeHelper.fromPxWidth(3);
	cancel.setLayoutParams(cancelParams);
	resid = ResHelper.getBitmapRes(context, "smssdk_dialog_btn_back");
	cancel.setBackgroundResource(resid);
	cancel.setPadding(padding, padding, padding, padding);
	resid = ResHelper.getStringRes(context, "smssdk_cancel");
	cancel.setText(resid);
	cancel.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	cancel.setTextColor(0xffffffff);
	wrapper.addView(cancel);

	root.addView(wrapper);
	return root;
}
 
Example 20
Project: EsperantoRadio   File: PagerSlidingTabStrip.java   View Source Code Vote up 4 votes
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);

  setFillViewport(true);
  setWillNotDraw(false);

  tabsContainer = new LinearLayout(context);
  tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
  tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  addView(tabsContainer);

  DisplayMetrics dm = getResources().getDisplayMetrics();

  scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
  indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
  underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
  dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
  tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
  dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
  tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);
  minBredde = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, minBredde, dm);

  // get system attrs (android:textSize and android:textColor)

  TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

  tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
  //noinspection ResourceType
  tabTextColor = a.getColor(1, tabTextColor);

  a.recycle();

  // get custom attrs

  a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

  indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
  underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
  dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
  indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight);
  underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight);
  dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding);
  tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
  tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId);
  shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
  scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
  textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

  a.recycle();

  rectPaint = new Paint();
  rectPaint.setAntiAlias(true);
  rectPaint.setStyle(Style.FILL);

  dividerPaint = new Paint();
  dividerPaint.setAntiAlias(true);
  dividerPaint.setStrokeWidth(dividerWidth);

  defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
  expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

  if (locale == null) {
    locale = getResources().getConfiguration().locale;
  }
}