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;
}
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;
}
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;
}
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();
}
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);
}
}
Aggregations