/** * Set the top padding on the header view dynamically, based on whether the header is in * the first row or not. */ public static void setHeaderViewBottomPadding(Context context, TextView textView, boolean isFirstRow) { final int topPadding; if (isFirstRow) { topPadding = (int) context.getResources().getDimension( R.dimen.frequently_contacted_title_top_margin_when_first_row); } else { topPadding = (int) context.getResources().getDimension( R.dimen.frequently_contacted_title_top_margin); } textView.setPaddingRelative(textView.getPaddingStart(), topPadding, textView.getPaddingEnd(), textView.getPaddingBottom()); }
public void into(TextView target) { if (this.target == null) { this.target = new WeakReference<>(target); } if (imageGetter == null) { WindowManager wm = (WindowManager) target.getContext() .getSystemService(Context.WINDOW_SERVICE); Point p = new Point(); wm.getDefaultDisplay().getSize(p); VIEW_WIDTH = p.x - target.getPaddingStart() - target.getPaddingEnd(); imageGetter = new DefaultImageGetter(target.getContext(), VIEW_WIDTH); } if (clickListener == null) { clickListener = new DefaultClickHandler(target.getContext()); } FONT_SIZE = target.getTextSize(); spanned = SpanConverter.convert(source, imageGetter, clickListener, this); target.setMovementMethod(LinkMovementMethod.getInstance()); target.setLinkTextColor(URL_COLOR); target.setLineSpacing(0, LINE_HEIGHT); target.setText(spanned); isViewSet = true; }
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) @Override public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { toolbar.setPadding(toolbar.getPaddingStart() /*+ insets.getSystemWindowInsetLeft()*/, toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() /*+ insets.getSystemWindowInsetRight()*/, toolbar.getPaddingBottom()); aboutText.setPadding(aboutText.getPaddingStart(), aboutText.getPaddingTop(), aboutText.getPaddingEnd(), aboutText.getPaddingBottom() + insets.getSystemWindowInsetBottom()); View viewGroup = findViewById(R.id.swipeBackView); ViewGroup.MarginLayoutParams viewGroupParams = (ViewGroup.MarginLayoutParams) viewGroup.getLayoutParams(); viewGroupParams.leftMargin += insets.getSystemWindowInsetLeft(); viewGroupParams.rightMargin += insets.getSystemWindowInsetRight(); viewGroup.setLayoutParams(viewGroupParams); // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } });