List of usage examples for android.view View getPaddingLeft
public int getPaddingLeft()
From source file:org.thoughtcrime.securesms.ConversationItem.java
@Override public void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (groupSenderHolder != null && groupSenderHolder.getVisibility() == View.VISIBLE) { View content = (View) groupSenderHolder.getParent(); groupSenderHolder.layout(content.getPaddingLeft(), content.getPaddingTop(), content.getWidth() - content.getPaddingRight(), content.getPaddingTop() + groupSenderHolder.getMeasuredHeight()); if (ViewCompat.getLayoutDirection(groupSenderProfileName) == ViewCompat.LAYOUT_DIRECTION_RTL) { groupSenderProfileName.layout(groupSenderHolder.getPaddingLeft(), groupSenderHolder.getPaddingTop(), groupSenderHolder.getPaddingLeft() + groupSenderProfileName.getWidth(), groupSenderHolder.getPaddingTop() + groupSenderProfileName.getHeight()); } else {//from w w w . j a va2s.c o m groupSenderProfileName.layout( groupSenderHolder.getWidth() - groupSenderHolder.getPaddingRight() - groupSenderProfileName.getWidth(), groupSenderHolder.getPaddingTop(), groupSenderHolder.getWidth() - groupSenderProfileName.getPaddingRight(), groupSenderHolder.getPaddingTop() + groupSenderProfileName.getHeight()); } } }
From source file:com.andrada.sitracker.ui.fragment.RemoteAuthorsFragment.java
public void onEvent(@NotNull AuthorAddedEvent event) { //Cancel any further delivery EventBus.getDefault().cancelEventDelivery(event); if (event.authorUrl != null) { //Find author with this url SearchedAuthor auth = adapter.getItemById(event.authorUrl); if (auth != null) { auth.setAdded(true);/* w ww . j ava2s. co m*/ ((BaseAdapter) list.getAdapter()).notifyDataSetChanged(); } } loading.setVisibility(View.GONE); String message = event.message; AnalyticsHelper.getInstance().sendEvent(Constants.GA_EXPLORE_CATEGORY, Constants.GA_EVENT_AUTHOR_ADDED, Constants.GA_EVENT_AUTHOR_ADDED); if (getActivity() == null) { return; } View view = getLayoutInflater(null).inflate(R.layout.crouton_custom_pos_textview, null); if (message.length() == 0) { message = getString(R.string.author_add_success_crouton_message); view.findViewById(android.R.id.background).setBackgroundColor(Style.holoGreenLight); } else { view.findViewById(android.R.id.background).setBackgroundColor(Style.holoRedLight); } int topPadding = UIUtils.calculateActionBarSize(getActivity()); view.setPadding(view.getPaddingLeft(), topPadding, view.getPaddingRight(), view.getPaddingBottom()); TextView tv = (TextView) view.findViewById(android.R.id.text1); tv.setText(message); Crouton cr = Crouton.make(getActivity(), view); cr.setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_LONG).build()); cr.show(); }
From source file:com.waz.zclient.pages.main.conversation.SingleImageFragment.java
private void loadClickedImageSizeAndPosition() { final View clickedImage = getControllerFactory().getSingleImageController().getImageContainer(); clickedImageHeight = clickedImage.getMeasuredHeight(); clickedImageWidth = clickedImage.getMeasuredWidth(); if (clickedImageHeight == 0 || clickedImageWidth == 0) { View parent = (View) clickedImage.getParent(); final int widthSpec = View.MeasureSpec.makeMeasureSpec( parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(), View.MeasureSpec.EXACTLY); final int heightSpec = View.MeasureSpec.makeMeasureSpec( parent.getMeasuredHeight() - parent.getPaddingTop() - parent.getPaddingBottom(), View.MeasureSpec.EXACTLY); clickedImage.measure(widthSpec, heightSpec); clickedImageHeight = clickedImage.getMeasuredHeight(); clickedImageWidth = clickedImage.getMeasuredWidth(); }//from w w w .java 2 s. c om clickedImageLocation = ViewUtils.getLocationOnScreen(clickedImage); int dx = 0; int dy = -ViewUtils.getStatusBarHeight(getActivity()); clickedImageLocation.offset(dx, dy); }
From source file:android.percent.support.PercentLayoutHelper.java
private void supportPadding(int widthHint, int heightHint, View view, PercentLayoutInfo info) { int left = view.getPaddingLeft(), right = view.getPaddingRight(), top = view.getPaddingTop(), bottom = view.getPaddingBottom(); PercentLayoutInfo.PercentVal percentVal = info.paddingLeftPercent; if (percentVal != null) { int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode); left = (int) (base * percentVal.percent); }/* ww w.j a v a2s . c om*/ percentVal = info.paddingRightPercent; if (percentVal != null) { int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode); right = (int) (base * percentVal.percent); } percentVal = info.paddingTopPercent; if (percentVal != null) { int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode); top = (int) (base * percentVal.percent); } percentVal = info.paddingBottomPercent; if (percentVal != null) { int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode); bottom = (int) (base * percentVal.percent); } view.setPadding(left, top, right, bottom); }
From source file:com.hgdendi.contactslist.common.FloatingBarItemDecoration.java
@Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { super.onDrawOver(c, parent, state); final int position = ((LinearLayoutManager) parent.getLayoutManager()).findFirstVisibleItemPosition(); if (position == RecyclerView.NO_POSITION) { return;//from w w w. ja va 2s .c o m } View child = parent.findViewHolderForAdapterPosition(position).itemView; String initial = getTag(position); if (initial == null) { return; } boolean flag = false; if (getTag(position + 1) != null && !initial.equals(getTag(position + 1))) { if (child.getHeight() + child.getTop() < mTitleHeight) { c.save(); flag = true; c.translate(0, child.getHeight() + child.getTop() - mTitleHeight); } } c.drawRect(parent.getPaddingLeft(), parent.getPaddingTop(), parent.getRight() - parent.getPaddingRight(), parent.getPaddingTop() + mTitleHeight, mBackgroundPaint); c.drawText(initial, child.getPaddingLeft() + mTextStartMargin, parent.getPaddingTop() + mTitleHeight - (mTitleHeight - mTextHeight) / 2 - mTextBaselineOffset, mTextPaint); if (flag) { c.restore(); } }
From source file:android.support.design.widget.BaseTransientBottomBar.java
/** * Constructor for the transient bottom bar. * * @param parent The parent for this transient bottom bar. * @param content The content view for this transient bottom bar. * @param contentViewCallback The content view callback for this transient bottom bar. *//* w ww . java2 s . c om*/ protected BaseTransientBottomBar(@NonNull ViewGroup parent, @NonNull View content, @NonNull ContentViewCallback contentViewCallback) { if (parent == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null parent"); } if (content == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null content"); } if (contentViewCallback == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null callback"); } mTargetParent = parent; mContentViewCallback = contentViewCallback; mContext = parent.getContext(); ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); // Note that for backwards compatibility reasons we inflate a layout that is defined // in the extending Snackbar class. This is to prevent breakage of apps that have custom // coordinator layout behaviors that depend on that layout. mView = (SnackbarBaseLayout) inflater.inflate(R.layout.design_layout_snackbar, mTargetParent, false); mView.addView(content); ViewCompat.setAccessibilityLiveRegion(mView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); ViewCompat.setImportantForAccessibility(mView, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); // Make sure that we fit system windows and have a listener to apply any insets ViewCompat.setFitsSystemWindows(mView, true); ViewCompat.setOnApplyWindowInsetsListener(mView, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { // Copy over the bottom inset as padding so that we're displayed // above the navigation bar v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), insets.getSystemWindowInsetBottom()); return insets; } }); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); }
From source file:com.commonsware.cwac.crossport.design.widget.BaseTransientBottomBar.java
/** * Constructor for the transient bottom bar. * * @param parent The parent for this transient bottom bar. * @param content The content view for this transient bottom bar. * @param contentViewCallback The content view callback for this transient bottom bar. */// w ww . j a va2s . c o m protected BaseTransientBottomBar(@NonNull ViewGroup parent, @NonNull View content, @NonNull ContentViewCallback contentViewCallback) { if (parent == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null parent"); } if (content == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null content"); } if (contentViewCallback == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null callback"); } mTargetParent = parent; mContentViewCallback = contentViewCallback; mContext = parent.getContext(); // ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); // Note that for backwards compatibility reasons we inflate a layout that is defined // in the extending Snackbar class. This is to prevent breakage of apps that have custom // coordinator layout behaviors that depend on that layout. mView = (SnackbarBaseLayout) inflater.inflate(R.layout.design_layout_snackbar, mTargetParent, false); mView.addView(content); ViewCompat.setAccessibilityLiveRegion(mView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); ViewCompat.setImportantForAccessibility(mView, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); // Make sure that we fit system windows and have a listener to apply any insets ViewCompat.setFitsSystemWindows(mView, true); ViewCompat.setOnApplyWindowInsetsListener(mView, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { // Copy over the bottom inset as padding so that we're displayed // above the navigation bar v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), insets.getSystemWindowInsetBottom()); return insets; } }); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); }
From source file:com.mark.quick.ui.view.snackbar.BaseTransientBottomBar.java
/** * Constructor for the transient bottom bar. * * @param parent The parent for this transient bottom bar. * @param content The content view for this transient bottom bar. * @param contentViewCallback The content view callback for this transient bottom bar. */// w ww. ja v a 2 s . co m protected BaseTransientBottomBar(@NonNull ViewGroup parent, @NonNull View content, @NonNull ContentViewCallback contentViewCallback) { if (parent == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null parent"); } if (content == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null content"); } if (contentViewCallback == null) { throw new IllegalArgumentException("Transient bottom bar must have non-null callback"); } mTargetParent = parent; mContentViewCallback = contentViewCallback; mContext = parent.getContext(); ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); // Note that for backwards compatibility reasons we inflate a layout that is defined // in the extending Snackbar class. This is to prevent breakage of apps that have custom // coordinator layout behaviors that depend on that layout. mView = (SnackbarBaseLayout) inflater.inflate(R.layout.mark_design_layout_snackbar, mTargetParent, false); mView.addView(content); ViewCompat.setAccessibilityLiveRegion(mView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); ViewCompat.setImportantForAccessibility(mView, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); // Make sure that we fit system windows and have a listener to apply any insets ViewCompat.setFitsSystemWindows(mView, true); ViewCompat.setOnApplyWindowInsetsListener(mView, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { // Copy over the bottom inset as padding so that we're displayed // above the navigation bar v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), insets.getSystemWindowInsetBottom()); return insets; } }); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); }
From source file:pageslidingtabstrip.ConsumingPagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;/*from w ww. j ava 2 s . c om*/ } final int height = getHeight(); rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); int tabwidth = 0; if (isShowLine) { tabwidth = currentTab.getPaddingLeft(); } // if there is an offset, start interpolating left and right coordinates // between current and next tab if (isShowUnderLine) { if (currentPositionOffset > 0f && currentPosition < tabCount - 1) { View nextTab = tabsContainer.getChildAt(currentPosition + 1); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); } canvas.drawRect(lineLeft + tabwidth, height - indicatorHeight, lineRight - tabwidth, height, rectPaint); // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); } // draw divider dividerPaint.setColor(dividerColor); if (isShowLine) { for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } } }
From source file:com.yan.stamped.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; TextView tabTitleView = null;// www.j a va2s . c o m 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(Color.WHITE); tabView.setOnClickListener(tabClickListener); tabView.setPadding(tabView.getPaddingLeft() + 27, tabView.getPaddingTop(), tabView.getPaddingRight() + 27, tabView.getPaddingBottom()); mTabStrip.addView(tabView); } }