Java Code Examples for android.widget.TextView#getLayoutParams()
The following examples show how to use
android.widget.TextView#getLayoutParams() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: SweetTips File: SweetToast.java License: Apache License 2.0 | 6 votes |
/** * 设置当前SweetToast实例的最小宽高 * 很有用的功能,参考了简书上的文章:http://www.jianshu.com/p/491b17281c0a * @param width SweetToast实例的最小宽度,单位是pix * @param height SweetToast实例的最小高度,单位是pix * @return */ public SweetToast minSize(int width, int height){ if(mContentView!=null && mContentView instanceof LinearLayout){ mContentView.setMinimumWidth(width); mContentView.setMinimumHeight(height); ((LinearLayout)mContentView).setGravity(Gravity.CENTER); try { TextView textView = ((TextView) mContentView.findViewById(R.id.message)); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.width = LinearLayout.LayoutParams.MATCH_PARENT; params.height = LinearLayout.LayoutParams.MATCH_PARENT; textView.setLayoutParams(params); textView.setGravity(Gravity.CENTER); }catch (Exception e){ Log.e("幻海流心","e:"+e.getLocalizedMessage()); } } return this; }
Example 2
Source Project: tysq-android File: MyFansAdapter.java License: GNU General Public License v3.0 | 6 votes |
/** * 改变关注状态 * * @param isAttention 是否关注 * @param button 关注按钮 * @param add +图片 * @param layout 父布局 */ private void changeBtnAttention(boolean isAttention, TextView button, ImageView add, RelativeLayout layout) { if (!isAttention) { layout.setVisibility(View.VISIBLE); layout.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_blue_rect)); button.setText(R.string.personal_focus_someone); add.setVisibility(View.VISIBLE); button.setTextColor(ContextCompat.getColor(getContext(), R.color.white)); } else { layout.setVisibility(View.VISIBLE); layout.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_dark_gray_fill_4dp)); button.setText(R.string.personal_focused); button.setTextColor(ContextCompat.getColor(getContext(), R.color.white)); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) button.getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); add.setVisibility(View.GONE); } }
Example 3
Source Project: SweetTips File: SnackbarUtils.java License: Apache License 2.0 | 6 votes |
/** * 设置TextView(@+id/snackbar_text)左右两侧的图片 * @param leftDrawable * @param rightDrawable * @return */ public SnackbarUtils leftAndRightDrawable(@Nullable Drawable leftDrawable, @Nullable Drawable rightDrawable){ if(getSnackbar()!=null){ TextView message = (TextView) getSnackbar().getView().findViewById(R.id.snackbar_text); LinearLayout.LayoutParams paramsMessage = (LinearLayout.LayoutParams) message.getLayoutParams(); paramsMessage = new LinearLayout.LayoutParams(paramsMessage.width, paramsMessage.height,0.0f); message.setLayoutParams(paramsMessage); message.setCompoundDrawablePadding(message.getPaddingLeft()); int textSize = (int) message.getTextSize(); Log.e("Jet","textSize:"+textSize); if(leftDrawable!=null){ leftDrawable.setBounds(0,0,textSize,textSize); } if(rightDrawable!=null){ rightDrawable.setBounds(0,0,textSize,textSize); } message.setCompoundDrawables(leftDrawable,null,rightDrawable,null); LinearLayout.LayoutParams paramsSpace = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT,1.0f); ((SweetSnackbar.SnackbarLayout)getSnackbar().getView()).addView(new Space(getSnackbar().getView().getContext()),1,paramsSpace); } return this; }
Example 4
Source Project: NewXmPluginSDK File: MLAlertController.java License: Apache License 2.0 | 5 votes |
private void centerButton(TextView button) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button.getLayoutParams(); params.gravity = Gravity.CENTER_HORIZONTAL; params.weight = 0.5f; button.setLayoutParams(params); button.setBackgroundResource(R.drawable.common_button); }
Example 5
Source Project: MarketAndroidApp File: MenuDialogAdapter.java License: Apache License 2.0 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.main_menu_item, null); } //绑定item内的TextView和RadioButton TextView nameText = MenuDialogAdapterViewHolder.get(convertView, R.id.menu_item_textview); RadioButton clickButton = MenuDialogAdapterViewHolder.get(convertView, R.id.radioButton); clickButton.setChecked(selectedPos == position);//改变点击选中状态 //修改item高度,使其达到甲方要求的每页10个item显示要求 ViewGroup.LayoutParams lp = nameText.getLayoutParams(); lp.height = parent.getHeight() / 10; //获取选中的item的标题 CommodityTypeModel menuData = menuDatas.get(position); String str = menuData.getName(); nameText.setText(str);//设置标题 convertView.setSelected(selectedPos == position);//设置选中时的view nameText.setSelected(selectedPos == position);//判断菜单的点击状态 //选中后的标题字体及RadioButton颜色 nameText.setTextColor(selectedPos == position ? 0xFF387ef5 : 0xFF222222); clickButton.setTextColor(selectedPos == position ? 0xFF787878 : 0xFF387ef5); return convertView; }
Example 6
Source Project: umeng_community_android File: LikeMeFeedAdapter.java License: MIT License | 5 votes |
@SuppressWarnings("deprecation") private void updateShareTextViewParams(TextView textView) { LayoutParams params = (LayoutParams) textView.getLayoutParams(); params.width = android.view.ViewGroup.LayoutParams.WRAP_CONTENT; params.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); textView.setBackgroundDrawable(null); }
Example 7
Source Project: UIWidget File: UIActionSheetDialog.java License: Apache License 2.0 | 5 votes |
/** * 创建取消按钮 */ private void createCancel() { if (TextUtils.isEmpty(mCancelStr)) { return; } mTvCancel = new TextView(mContext); mTvCancel.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mTvCancel.setMinimumHeight(mItemsMinHeight); mTvCancel.setId(R.id.tv_cancelActionSheetDialog); mLLayoutRoot.addView(mTvCancel); mTvCancel.setLineSpacing(mLineSpacingExtra, mLineSpacingMultiplier); mTvCancel.setGravity(mCancelGravity); mTvCancel.setCompoundDrawablePadding(mTextDrawablePadding); mTvCancel.setPadding(mItemsTextPaddingLeft, mItemsTextPaddingTop, mItemsTextPaddingRight, mItemsTextPaddingBottom); mTvCancel.setText(mCancelStr); mTvCancel.setTextSize(mTextSizeUnit, mCancelTextSize); mTvCancel.setTextColor(mCancelTextColor); if (mCancelMarginTop > 0) { ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mTvCancel.getLayoutParams(); if (lp != null) { lp.topMargin = mCancelMarginTop; mTvCancel.setLayoutParams(lp); } } boolean single = mCancelMarginTop > 0 || TextUtils.isEmpty(mTitleStr) && mViewItem == null || mBottomDrawable == null; setViewBackground(mTvCancel, DrawableUtil.getNewDrawable(single ? mStateDrawableSingle : mStateDrawableBottom)); mTvCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDialog.dismiss(); } }); setTextViewLine(mTvCancel); }
Example 8
Source Project: px-android File: ElementDescriptorView.java License: MIT License | 5 votes |
private void configureTextView(final TextView text, final float textSize, final int textColor, final int textMaxLines, final int gravity) { text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); text.setTextColor(textColor); if (textMaxLines != DEFAULT_MAX_LINES) { text.setMaxLines(textMaxLines); } final LayoutParams titleParams = (LayoutParams) text.getLayoutParams(); titleParams.gravity = gravity; text.setLayoutParams(titleParams); }
Example 9
Source Project: codeexamples-android File: AndroidActivityTest.java License: Eclipse Public License 1.0 | 5 votes |
@Test public void shouldHaveDefaultMargin() { RobolectricActivity activity = rule.getActivity(); TextView textView = (TextView) activity.findViewById(R.id.hello_textview); int bottomMargin = ((LinearLayout.LayoutParams) textView.getLayoutParams()).bottomMargin; assertEquals(dpToPx(activity.getApplicationContext(),5), bottomMargin); int topMargin = ((LinearLayout.LayoutParams) textView.getLayoutParams()).topMargin; assertEquals(dpToPx(activity.getApplicationContext(),5), topMargin); int rightMargin = ((LinearLayout.LayoutParams) textView.getLayoutParams()).rightMargin; assertEquals(dpToPx(activity.getApplicationContext(),10), rightMargin); int leftMargin = ((LinearLayout.LayoutParams) textView.getLayoutParams()).leftMargin; assertEquals(dpToPx(activity.getApplicationContext(),10) , leftMargin); }
Example 10
Source Project: YCVideoPlayer File: ChangeClarityDialog.java License: Apache License 2.0 | 5 votes |
/** * 设置清晰度等级 * @param items 清晰度等级items * @param defaultChecked 默认选中的清晰度索引 */ public void setClarityGrade(List<String> items, int defaultChecked) { mCurrentCheckedIndex = defaultChecked; for (int i = 0; i < items.size(); i++) { TextView itemView = (TextView) LayoutInflater.from(getContext()) .inflate(R.layout.change_video_clarity, mLinearLayout, false); itemView.setTag(i); itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mListener != null) { int checkIndex = (int) v.getTag(); if (checkIndex != mCurrentCheckedIndex) { for (int j = 0; j < mLinearLayout.getChildCount(); j++) { mLinearLayout.getChildAt(j).setSelected(checkIndex == j); } mListener.onClarityChanged(checkIndex); mCurrentCheckedIndex = checkIndex; } else { mListener.onClarityNotChanged(); } } ChangeClarityDialog.this.dismiss(); } }); itemView.setText(items.get(i)); itemView.setSelected(i == defaultChecked); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) itemView.getLayoutParams(); params.topMargin = (i == 0) ? 0 : VideoPlayerUtils.dp2px(getContext(), 16f); mLinearLayout.addView(itemView, params); } }
Example 11
Source Project: XPrivacy File: ActivityMain.java License: GNU General Public License v3.0 | 5 votes |
@Override @SuppressWarnings("unchecked") protected void publishResults(CharSequence constraint, FilterResults results) { if (results != null) { clear(); TextView tvStats = (TextView) findViewById(R.id.tvStats); TextView tvState = (TextView) findViewById(R.id.tvState); ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter); pbFilter.setVisibility(ProgressBar.GONE); tvStats.setVisibility(TextView.VISIBLE); runOnUiThread(new Runnable() { @Override public void run() { setProgress(getString(R.string.title_restrict), 0, 1); } }); // Adjust progress state width RelativeLayout.LayoutParams tvStateLayout = (RelativeLayout.LayoutParams) tvState.getLayoutParams(); tvStateLayout.addRule(RelativeLayout.LEFT_OF, R.id.tvStats); if (results.values == null) notifyDataSetInvalidated(); else { addAll((ArrayList<ApplicationInfoEx>) results.values); notifyDataSetChanged(); } AppListAdapter.this.showStats(); } }
Example 12
Source Project: youqu_master File: ExpandTextView.java License: Apache License 2.0 | 5 votes |
/** * 初始化 */ private void init() { View.inflate(mContext, R.layout.expand_text_view, this); mTitleView = (TextView) findViewById(R.id.tv_title); mContentView = (TextView) findViewById(R.id.tv_content); mHintView = (TextView) findViewById(R.id.tv_more_hint); mIndicateImage = (ImageView) findViewById(R.id.iv_arrow_more); mShowMore = (RelativeLayout) findViewById(R.id.rl_show_more); mTitleView.setText(title); mTitleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize); mTitleView.setTextColor(titleTextColor); mContentView.setText(content); mContentView.setTextSize(TypedValue.COMPLEX_UNIT_PX, contentTextSize); mContentView.setTextColor(contentTextColor); mHintView.setText(expandHint); mHintView.setTextSize(TypedValue.COMPLEX_UNIT_PX, hintTextSize); mHintView.setTextColor(hintTextColor); if (indicateImage == null) { indicateImage = getResources().getDrawable(R.drawable.ic_arrow_down_light_round); } mIndicateImage.setImageDrawable(indicateImage); mShowMore.setOnClickListener(this); ViewGroup.LayoutParams layoutParams = mContentView.getLayoutParams(); layoutParams.height = getMinMeasureHeight(); mContentView.setLayoutParams(layoutParams); }
Example 13
Source Project: FixMath File: TimeAttackActivity.java License: Apache License 2.0 | 5 votes |
private void setCorrectFrameFigure(ImageView correctFrameFigure, int index) { TextView correctFrameTextView = (TextView) findViewById(R.id.correctFigure_1); int correctFrameFigureWidth = correctFrameTextView.getLayoutParams().width; int correctFrameFigureHeight = correctFrameTextView.getLayoutParams().height; if (level.GetTimeAttackCorrectFigures(index).equals("k")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.kwadrat_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); } else if (level.GetTimeAttackCorrectFigures(index).equals("o")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.okrag_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); } else if (level.GetTimeAttackCorrectFigures(index).equals("r")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.romb_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); } else if (level.GetTimeAttackCorrectFigures(index).equals("s")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.skat_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); } else if (level.GetTimeAttackCorrectFigures(index).equals("rf")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.romb_f_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); } else if (level.GetTimeAttackCorrectFigures(index).equals("oz")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.okrag_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); } else if (level.GetTimeAttackCorrectFigures(index).equals("ok")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.okat_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); } else if (level.GetTimeAttackCorrectFigures(index).equals("q")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.question_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); }else if (level.GetTimeAttackCorrectFigures(index).equals("kf")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.kwadrat_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); }else if (level.GetTimeAttackCorrectFigures(index).equals("kb")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.kwadrat_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); }else if (level.GetTimeAttackCorrectFigures(index).equals("rg")) { correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(), R.drawable.romb_ramka, correctFrameFigureWidth, correctFrameFigureHeight)); } }
Example 14
Source Project: iTab File: MainActivity.java License: Apache License 2.0 | 5 votes |
private View createTabIndicator(String label, Drawable drawable) { View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, mTabHost.getTabWidget(), false); TextView txtTitle = (TextView) tabIndicator.findViewById(R.id.text_view_tab_title); txtTitle.setText(label); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) txtTitle.getLayoutParams(); txtTitle.setLayoutParams(params); ImageView imgIcon = (ImageView) tabIndicator.findViewById(R.id.image_view_tab_icon); imgIcon.setImageDrawable(drawable); return tabIndicator; }
Example 15
Source Project: BottomNavigation File: BadgeItem.java License: Apache License 2.0 | 5 votes |
/** * @param gravity gravity of badge (TOP|LEFT ..etc) * @return this, to allow builder pattern */ public T setGravity(int gravity) { this.mGravity = gravity; if (isWeakReferenceValid()) { TextView textView = mTextViewRef.get(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textView.getLayoutParams(); layoutParams.gravity = gravity; textView.setLayoutParams(layoutParams); } return getSubInstance(); }
Example 16
Source Project: RxTools-master File: RxPopupViewCoordinatesFinder.java License: Apache License 2.0 | 5 votes |
private static void AdjustHorizotalRightAlignmentOutOfBounds(TextView tipView, ViewGroup root, Point point, RxCoordinates anchorViewRxCoordinates, RxCoordinates rootLocation) { ViewGroup.LayoutParams params = tipView.getLayoutParams(); int rootLeft = rootLocation.left + root.getPaddingLeft(); if (point.x < rootLeft){ int availableSpace = anchorViewRxCoordinates.right - rootLeft; point.x = rootLeft; params.width = availableSpace; params.height = ViewGroup.LayoutParams.WRAP_CONTENT; tipView.setLayoutParams(params); measureViewWithFixedWidth(tipView, params.width); } }
Example 17
Source Project: xposed-rimet File: DingDingDialog.java License: Apache License 2.0 | 4 votes |
@Override protected void initView(View view, Bundle args) { super.initView(view, args); // 创建对象 // mRimetPresenter = new RimetPresenter(getPluginManager(), this); setTitle(Constant.Name.TITLE); TextView tvExt = sivSettingsLocation.getExtendView(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) tvExt.getLayoutParams(); params.leftMargin = DisplayUtil.dip2px(getContext(), 100); tvExt.setMaxLines(2); tvExt.setEllipsize(TextUtils.TruncateAt.END); tvExt.setTextSize(12); SharedPreferences preferences = getDefaultSharedPreferences(); XPlugin xPlugin = getPluginManager().getXPluginById(Constant.Plugin.DING_DING); sivLuckyEnable.bind(getDefaultSharedPreferences(), Integer.toString(Constant.XFlag.ENABLE_LUCKY), true, (view1, key, value) -> { xPlugin.setEnable(Constant.XFlag.ENABLE_LUCKY, value); return true; }); sivLuckyDelayed.bind(getDefaultSharedPreferences(), Integer.toString(Constant.XFlag.LUCKY_DELAYED), "", (view12, key, value) -> true); sivFastLuckyEnable.bind(getDefaultSharedPreferences(), Integer.toString(Constant.XFlag.ENABLE_FAST_LUCKY), true, (view1, key, value) -> { xPlugin.setEnable(Constant.XFlag.ENABLE_FAST_LUCKY, value); return true; }); sivRecallEnable.bind(getDefaultSharedPreferences(), Integer.toString(Constant.XFlag.ENABLE_RECALL), true, (view1, key, value) -> { xPlugin.setEnable(Constant.XFlag.ENABLE_RECALL, value); return true; }); sivLocationEnable.bind(getDefaultSharedPreferences(), Integer.toString(Constant.XFlag.ENABLE_LOCATION), false, (view1, key, value) -> { xPlugin.setEnable(Constant.XFlag.ENABLE_LOCATION, value); return true; }); // 设置初始信息 sivSettingsLocation.setExtend(preferences.getString( Integer.toString(Constant.XFlag.ADDRESS), "")); sivSettingsLocation.setOnClickListener(v -> { // 跳转到地图界面 Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClassName(BuildConfig.APPLICATION_ID, MapActivity.class.getName()); startActivityForResult(intent, 99); }); sivLove.setOnClickListener(v -> { // 打开捐赠界面 LoveDialog loveDialog = new LoveDialog(); loveDialog.show(getFragmentManager(), "love"); }); sivAbout.setOnClickListener(v -> { // 打开关于界面 DialogUtil.showAboutDialog(getContext()); }); // 是否支持版本 XConfig xConfig = getPluginManager().getVersionManager().getSupportConfig(); setPromptText(xConfig != null ? "" : "不支持当前版本!"); }
Example 18
Source Project: Telegram File: ActionBarMenuItem.java License: GNU General Public License v2.0 | 4 votes |
public TextView addSubItem(int id, CharSequence text) { createPopupLayout(); TextView textView = new TextView(getContext()); textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem)); textView.setBackgroundDrawable(Theme.getSelectorDrawable(false)); if (!LocaleController.isRTL) { textView.setGravity(Gravity.CENTER_VERTICAL); } else { textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT); } textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setMinWidth(AndroidUtilities.dp(196)); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTag(id); textView.setText(text); popupLayout.addView(textView); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams(); if (LocaleController.isRTL) { layoutParams.gravity = Gravity.RIGHT; } layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(48); textView.setLayoutParams(layoutParams); textView.setOnClickListener(view -> { if (popupWindow != null && popupWindow.isShowing()) { if (processedPopupClick) { return; } processedPopupClick = true; if (!allowCloseAnimation) { popupWindow.setAnimationStyle(R.style.PopupAnimation); } popupWindow.dismiss(allowCloseAnimation); } if (parentMenu != null) { parentMenu.onItemClick((Integer) view.getTag()); } else if (delegate != null) { delegate.onItemClick((Integer) view.getTag()); } }); return textView; }
Example 19
Source Project: letv File: AlbumVideoController.java License: Apache License 2.0 | 4 votes |
private void initNonCopyrightBtn(TextView textView) { textView.setBackgroundResource(R.drawable.noncopyright_album_play_btn); textView.getLayoutParams().width = UIsUtils.dipToPx(40.0f); textView.getLayoutParams().height = UIsUtils.dipToPx(19.0f); textView.setTextColor(Color.parseColor("#ccfcfcfc")); }
Example 20
Source Project: UltimateRecyclerView File: BaseViewHolder.java License: Apache License 2.0 | 4 votes |
protected RelativeLayout.LayoutParams getParamsLayoutOffset(TextView layout, T itemData) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams(); params.leftMargin = itemMargin * itemData.getTreeDepth() + offsetMargin; return params; }