Search in sources :

Example 16 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project androidquery by androidquery.

the class RatioDrawable method adjust.

private void adjust(ImageView iv, Bitmap bm, boolean done) {
    int vw = getWidth(iv);
    if (vw <= 0)
        return;
    int dw = bm.getWidth();
    int dh = bm.getHeight();
    int th = targetHeight(dw, dh, vw) + iv.getPaddingTop() + iv.getPaddingBottom();
    LayoutParams lp = iv.getLayoutParams();
    if (lp == null)
        return;
    int vh = lp.height;
    if (th != vh) {
        lp.height = th;
        iv.setLayoutParams(lp);
    }
    if (done)
        adjusted = true;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams)

Example 17 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project androidquery by androidquery.

the class RatioDrawable method getWidth.

private int getWidth(ImageView iv) {
    int width = 0;
    LayoutParams lp = iv.getLayoutParams();
    if (lp != null)
        width = lp.width;
    if (width <= 0) {
        width = iv.getWidth();
    }
    if (width > 0) {
        width = width - iv.getPaddingLeft() - iv.getPaddingRight();
    }
    return width;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams)

Example 18 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project ListViewAnimations by nhaarman.

the class ExpandableListItemAdapter method getView.

@Override
@NonNull
public View getView(final int position, @Nullable final View convertView, @NonNull 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.equals(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.equals(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) View(android.view.View) NonNull(android.support.annotation.NonNull)

Example 19 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project androidquery by androidquery.

the class AbstractAQuery method margin.

/**
	 * Set the margin of a view. Notes all parameters are in DIP, not in pixel.
	 *
	 * @param leftDip the left dip
	 * @param topDip the top dip
	 * @param rightDip the right dip
	 * @param bottomDip the bottom dip
	 * @return self
	 */
public T margin(float leftDip, float topDip, float rightDip, float bottomDip) {
    if (view != null) {
        LayoutParams lp = view.getLayoutParams();
        if (lp instanceof MarginLayoutParams) {
            Context context = getContext();
            int left = AQUtility.dip2pixel(context, leftDip);
            int top = AQUtility.dip2pixel(context, topDip);
            int right = AQUtility.dip2pixel(context, rightDip);
            int bottom = AQUtility.dip2pixel(context, bottomDip);
            ((MarginLayoutParams) lp).setMargins(left, top, right, bottom);
            view.setLayoutParams(lp);
        }
    }
    return self();
}
Also used : Context(android.content.Context) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) Paint(android.graphics.Paint)

Example 20 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project androidquery by androidquery.

the class AbstractAQuery method size.

private void size(boolean width, int n, boolean dip) {
    if (view != null) {
        LayoutParams lp = view.getLayoutParams();
        Context context = getContext();
        if (n > 0 && dip) {
            n = AQUtility.dip2pixel(context, n);
        }
        if (width) {
            lp.width = n;
        } else {
            lp.height = n;
        }
        view.setLayoutParams(lp);
    }
}
Also used : Context(android.content.Context) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams)

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