@Override protected int getApproximateImageSize() { return ViewUtil.getConstantPreLayoutWidth(getPhotoView()); } }
private void onLayoutForTiles() { final int count = getChildCount(); // Amount of margin needed on the left is based on difference between offset and padding int childLeft = mWhitespaceStartEnd - (mPaddingInPixels + 1) / 2; // Just line up children horizontally. for (int i = 0; i < count; i++) { final int rtlAdjustedIndex = ViewUtil.isViewLayoutRtl(this) ? count - i - 1 : i; final View child = getChildAt(rtlAdjustedIndex); // Note MeasuredWidth includes the padding. final int childWidth = child.getMeasuredWidth(); child.layout(childLeft, 0, childLeft + childWidth, child.getMeasuredHeight()); childLeft += childWidth; } }
public FloatingActionButtonController(Activity activity, View container, ImageButton button) { Resources resources = activity.getResources(); mFabInterpolator = AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in); mFloatingActionButtonWidth = resources.getDimensionPixelSize( R.dimen.floating_action_button_width); mFloatingActionButtonMarginRight = resources.getDimensionPixelOffset( R.dimen.floating_action_button_margin_right); mAnimationDuration = resources.getInteger( R.integer.floating_action_button_animation_duration); mFloatingActionButtonContainer = container; mFloatingActionButton = button; ViewUtil.setupFloatingActionButton(mFloatingActionButtonContainer, resources); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ViewUtil.addBottomPaddingToListViewForFab(getListView(), getResources()); }
@Override public void onViewCreated(View view, android.os.Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mEmptyListView = (EmptyContentView) view.findViewById(R.id.empty_list_view); mEmptyListView.setImage(R.drawable.empty_contacts); mEmptyListView.setDescription(R.string.all_contacts_empty); mEmptyListView.setActionClickedListener(this); getListView().setEmptyView(mEmptyListView); mEmptyListView.setVisibility(View.GONE); ViewUtil.addBottomPaddingToListViewForFab(getListView(), getResources()); }
private void drawHeader(Canvas canvas, PinnedHeader header, long currentTime) { if (header.animating) { int timeLeft = (int)(header.targetTime - currentTime); if (timeLeft <= 0) { header.y = header.targetY; header.visible = header.targetVisible; header.animating = false; } else { header.y = header.targetY + (header.sourceY - header.targetY) * timeLeft / mAnimationDuration; } } if (header.visible) { View view = header.view; int saveCount = canvas.save(); int translateX = ViewUtil.isViewLayoutRtl(this) ? getWidth() - mHeaderPaddingStart - view.getWidth() : mHeaderPaddingStart; canvas.translate(translateX, header.y); if (header.state == FADING) { mBounds.set(0, 0, view.getWidth(), view.getHeight()); canvas.saveLayerAlpha(mBounds, header.alpha, Canvas.ALL_SAVE_FLAG); } view.draw(canvas); canvas.restoreToCount(saveCount); } } }
@Override protected int getApproximateImageSize() { return ViewUtil.getConstantPreLayoutWidth(getQuickContact()); }
/** * Sets section header or makes it invisible if the title is null. */ public void setSectionHeader(String title) { if (!TextUtils.isEmpty(title)) { if (mHeaderTextView == null) { mHeaderTextView = new TextView(getContext()); mHeaderTextView.setTextAppearance(getContext(), R.style.SectionHeaderStyle); mHeaderTextView.setGravity( ViewUtil.isViewLayoutRtl(this) ? Gravity.RIGHT : Gravity.LEFT); addView(mHeaderTextView); } setMarqueeText(mHeaderTextView, title); mHeaderTextView.setVisibility(View.VISIBLE); mHeaderTextView.setAllCaps(true); } else if (mHeaderTextView != null) { mHeaderTextView.setVisibility(View.GONE); } }
public ContactListPinnedHeaderView(Context context, AttributeSet attrs, View parent) { super(context, attrs); if (R.styleable.ContactListItemView == null) { return; } TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ContactListItemView); int backgroundColor = a.getColor( R.styleable.ContactListItemView_list_item_background_color, Color.WHITE); int textOffsetTop = a.getDimensionPixelSize( R.styleable.ContactListItemView_list_item_text_offset_top, 0); int paddingStartOffset = a.getDimensionPixelSize( R.styleable.ContactListItemView_list_item_padding_left, 0); int textWidth = getResources().getDimensionPixelSize( R.dimen.contact_list_section_header_width); int widthIncludingPadding = paddingStartOffset + textWidth; a.recycle(); setBackgroundColor(backgroundColor); setTextAppearance(getContext(), R.style.SectionHeaderStyle); setLayoutParams(new LayoutParams(widthIncludingPadding, LayoutParams.WRAP_CONTENT)); setLayoutDirection(parent.getLayoutDirection()); setGravity(Gravity.CENTER_VERTICAL | (ViewUtil.isViewLayoutRtl(this) ? Gravity.RIGHT : Gravity.LEFT)); // Apply text top offset. Multiply by two, because we are implementing this by padding for a // vertically centered view, rather than adjusting the position directly via a layout. setPaddingRelative( getPaddingStart() + paddingStartOffset, getPaddingTop() + (textOffsetTop * 2), getPaddingEnd(), getPaddingBottom()); }
int rightBound = width - getPaddingRight(); final boolean isLayoutRtl = ViewUtil.isViewLayoutRtl(this);