Search in sources :

Example 81 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project UltimateAndroid by cymcsg.

the class UnfoldAnimation method animate.

@Override
public void animate() {
    final ViewGroup parentView = (ViewGroup) view.getParent();
    final int positionView = parentView.indexOfChild(view);
    final FoldLayout mFoldLayout = new FoldLayout(view.getContext());
    mFoldLayout.setLayoutParams(new LayoutParams(view.getWidth(), view.getHeight()));
    mFoldLayout.setX(view.getLeft());
    mFoldLayout.setY(view.getTop());
    parentView.removeView(view);
    parentView.addView(mFoldLayout, positionView);
    mFoldLayout.addView(view);
    view.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING);
    mFoldLayout.setNumberOfFolds(numOfFolds);
    mFoldLayout.setOrientation(orientation);
    mFoldLayout.setAnchorFactor(anchorFactor);
    mFoldLayout.setFoldFactor(1);
    mFoldLayout.setVisibility(View.INVISIBLE);
    final ObjectAnimator foldInAnim = ObjectAnimator.ofFloat(mFoldLayout, "foldFactor", 1, 0);
    foldInAnim.setDuration(duration);
    foldInAnim.setInterpolator(interpolator);
    foldInAnim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (getListener() != null) {
                getListener().onAnimationEnd(UnfoldAnimation.this);
            }
        }
    });
    foldInAnim.start();
    ObjectAnimator foldOutAnim = ObjectAnimator.ofFloat(mFoldLayout, "foldFactor", 1);
    foldOutAnim.setDuration(1);
    foldOutAnim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mFoldLayout.setVisibility(View.VISIBLE);
            view.setVisibility(View.VISIBLE);
            foldInAnim.start();
        }
    });
    foldOutAnim.start();
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ViewGroup(android.view.ViewGroup) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 82 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project UltimateAndroid by cymcsg.

the class HighlightAnimation method animate.

@Override
public void animate() {
    final FrameLayout highlightFrame = new FrameLayout(view.getContext());
    LayoutParams layoutParams = new LayoutParams(view.getWidth(), view.getHeight());
    ImageView highlightView = new ImageView(view.getContext());
    highlightView.setBackgroundColor(color);
    highlightView.setAlpha(0.5f);
    highlightView.setVisibility(View.VISIBLE);
    final ViewGroup parentView = (ViewGroup) view.getParent();
    final int positionView = parentView.indexOfChild(view);
    parentView.addView(highlightFrame, positionView, layoutParams);
    highlightFrame.setX(view.getLeft());
    highlightFrame.setY(view.getTop());
    parentView.removeView(view);
    highlightFrame.addView(view);
    highlightFrame.addView(highlightView);
    highlightView.animate().alpha(0).setInterpolator(interpolator).setDuration(duration).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            highlightFrame.removeAllViews();
            parentView.addView(view, positionView);
            view.setX(highlightFrame.getLeft());
            view.setY(highlightFrame.getTop());
            parentView.removeView(highlightFrame);
            if (getListener() != null) {
                getListener().onAnimationEnd(HighlightAnimation.this);
            }
        }
    });
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) Animator(android.animation.Animator) ViewGroup(android.view.ViewGroup) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView)

Example 83 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project UltimateAndroid by cymcsg.

the class ExpandableListItemAdapter method getView.

@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
    ViewGroup view = (ViewGroup) convertView;
    ViewHolder viewHolder;
    if (view == null) {
        view = createView(parent);
        viewHolder = new ViewHolder();
        viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId);
        viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId);
        view.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) view.getTag();
    }
    View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent);
    if (titleView != viewHolder.titleView) {
        viewHolder.titleParent.removeAllViews();
        viewHolder.titleParent.addView(titleView);
        if (mActionViewResId == 0) {
            view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent));
        } else {
            view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent));
        }
    }
    viewHolder.titleView = titleView;
    View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent);
    if (contentView != viewHolder.contentView) {
        viewHolder.contentParent.removeAllViews();
        viewHolder.contentParent.addView(contentView);
    }
    viewHolder.contentView = contentView;
    viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE);
    viewHolder.contentParent.setTag(getItemId(position));
    LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams();
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    viewHolder.contentParent.setLayoutParams(layoutParams);
    return view;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) View(android.view.View)

Example 84 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project UltimateAndroid by cymcsg.

the class DefaultSectionAdapter method getHeaderViewForSection.

@Override
public View getHeaderViewForSection(int section, View convertView, ViewGroup parent) {
    TextView tv = null;
    if (convertView != null) {
        tv = (TextView) convertView;
    } else {
        tv = new TextView(context);
    }
    tv.setFocusable(false);
    tv.setBackgroundColor(Color.GRAY);
    tv.setLayoutParams(new LayoutParams(300, headerHeight));
    tv.setText("section header" + section);
    return tv;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TextView(android.widget.TextView)

Example 85 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project FreeFlow by Comcast.

the class DefaultSectionAdapter method getHeaderViewForSection.

@Override
public View getHeaderViewForSection(int section, View convertView, ViewGroup parent) {
    TextView tv = null;
    if (convertView != null) {
        tv = (TextView) convertView;
    } else {
        tv = new TextView(context);
    }
    tv.setFocusable(false);
    tv.setBackgroundColor(Color.GRAY);
    tv.setLayoutParams(new LayoutParams(300, headerHeight));
    tv.setText("section header" + section);
    return tv;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TextView(android.widget.TextView)

Aggregations

LayoutParams (android.view.ViewGroup.LayoutParams)265 TextView (android.widget.TextView)56 View (android.view.View)50 ViewGroup (android.view.ViewGroup)50 FrameLayout (android.widget.FrameLayout)35 LinearLayout (android.widget.LinearLayout)33 ImageView (android.widget.ImageView)30 Test (org.junit.Test)26 Paint (android.graphics.Paint)22 ListView (android.widget.ListView)22 ScrollView (android.widget.ScrollView)22 Context (android.content.Context)19 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)19 AdapterView (android.widget.AdapterView)17 RelativeLayout (android.widget.RelativeLayout)14 DisplayMetrics (android.util.DisplayMetrics)12 CheckedTextView (android.widget.CheckedTextView)12 Rect (android.graphics.Rect)9 ViewParent (android.view.ViewParent)9 TypedArray (android.content.res.TypedArray)8