本文整理汇总了Java中android.widget.AbsListView.LayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.LayoutParams方法的具体用法?Java AbsListView.LayoutParams怎么用?Java AbsListView.LayoutParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AbsListView
的用法示例。
在下文中一共展示了AbsListView.LayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getView
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
int padding = (int) (mDisplayMetrics.density * 10);
TextView tv = new TextView(mContext);
tv.setText(mItems[position]);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tv.setTextColor(Color.parseColor("#468ED0"));
// tv.setGravity(Gravity.CENTER);
tv.setPadding(padding, padding, padding, padding);
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
AbsListView.LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(lp);
return tv;
}
示例2: measureItem
import android.widget.AbsListView; //导入方法依赖的package包/类
private void measureItem(View item) {
ViewGroup.LayoutParams lp = item.getLayoutParams();
if (lp == null) {
lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
item.setLayoutParams(lp);
}
int wspec = ViewGroup.getChildMeasureSpec(mWidthMeasureSpec, getListPaddingLeft()
+ getListPaddingRight(), lp.width);
int hspec;
if (lp.height > 0) {
hspec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY);
} else {
hspec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
item.measure(wspec, hspec);
}
示例3: getView
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
int padding = (int) (mDisplayMetrics.density * 10);
TextView tv = (TextView) getLayoutInflater().inflate(R.layout.simple_spinner_item, null);
tv.setText(mItems[position]);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tv.setTextAppearance(SplashActivity.this, R.style.SkinCompatTextAppearance);
tv.setGravity(Gravity.CENTER);
tv.setPadding(padding, padding, padding, padding);
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
AbsListView.LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(lp);
return tv;
}
示例4: updateViewLayoutParams
import android.widget.AbsListView; //导入方法依赖的package包/类
private void updateViewLayoutParams(View view, int width, int height) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams == null || layoutParams.height != width || layoutParams.width != height) {
layoutParams = new AbsListView.LayoutParams(width, height);
view.setLayoutParams(layoutParams);
}
}
示例5: updateViewLayoutParams
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* Update the LayoutParams of the given View
*
* @param view The View to layout
* @param width The wanted width
* @param height The wanted height
*/
public static void updateViewLayoutParams(View view, int width, int height) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams == null || layoutParams.height != width || layoutParams.width != height) {
layoutParams = new AbsListView.LayoutParams(width, height);
view.setLayoutParams(layoutParams);
}
}
示例6: initCellSize
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* 初始化cell的size
*
* @param cell
* @param position
*/
private void initCellSize(final UDLuaTable cell, final int position) {
final View view = cell.getView();
if (view != null) {
int[] size = this.mLuaUserData.callCellSize(cell, position);
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams == null) {
layoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
layoutParams.width = size[0];
layoutParams.height = size[1];
view.setLayoutParams(layoutParams);
}
}
示例7: initCellSize
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* 调用LuaView的Init方法进行Cell的初始化
*
* @param position
* @return
*/
private void initCellSize(UDLuaTable cell, int position) {
final View view = cell.getView();
if (view != null) {
int[] size = mLuaUserData.callCellSize(cell, position);
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams == null) {
layoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
layoutParams.width = size[0];
layoutParams.height = size[1];
view.setLayoutParams(layoutParams);
}
}
示例8: setHeight
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* This call is exposed for the benefit of the animators.
*
* @param height The height of the current view.
*/
public void setHeight(int height) {
AbsListView.LayoutParams params = (AbsListView.LayoutParams) getLayoutParams();
if (params == null) {
params = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
} else {
if (params.height == height) return;
params.height = height;
}
setLayoutParams(params);
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:16,代码来源:AccessibilityTabModelListItem.java
示例9: createImageView
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* 创建要显示的ImageView
*/
private ImageView createImageView(String url) {
ImageView imageView = new ImageView(mContext);
// AbsListView 用于实现条目的虚拟列表的基类. 这里的列表没有空间的定义。 例如,该类的子类可以以网格的形式、走马灯的形式显示,或者作为堆栈等等。
AbsListView.LayoutParams params = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
imageView.setLayoutParams(params);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
// 加载图片
ImageLoader.getInstance().displayImage(url, imageView, App.getDefaultOptionsBuilder());
return imageView;
}
示例10: getView
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public View getView(final int i, final View view, ViewGroup viewGroup) {
final Button img = new Button(context);
int width = ScreenUtils.getScreenWidth(context) - DensityUtils.dp2px(context, 45);// 获取屏幕宽度
int height = 0;
width = width / 5;// 对当前的列数进行设置imgView的宽度
height = width * 5 / 6;
if (!weeklist[i]) {
img.setBackgroundResource(R.color.new_grty);
} else {
img.setBackgroundResource(R.color.colorPrimary);
}
img.setText(String.valueOf(i + 1));
img.setTextColor(Color.WHITE);
AbsListView.LayoutParams layout = new AbsListView.LayoutParams(width, height);
img.setLayoutParams(layout);
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onItemClickListener != null) {
onItemClickListener.onItemClick(v, i, view.getId());
}
}
});
return img;
}
示例11: getView
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
final Button img = new Button(context);
int width = ScreenUtils.getScreenWidth(context) - DensityUtils.dp2px(context, 45);// 获取屏幕宽度
int height = 0;
width = width / 5;// 对当前的列数进行设置imgView的宽度
height = width * 5 / 6;
if (!weeklist[position]) {
img.setBackgroundResource(R.color.new_grty);
} else {
img.setBackgroundResource(R.color.colorPrimary);
}
img.setText(String.valueOf(position + 1));
img.setTextColor(Color.WHITE);
AbsListView.LayoutParams layout = new AbsListView.LayoutParams(width, height);
img.setLayoutParams(layout);
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (type == SHOW_COURSE)
return;
if (weeklist[position]) {
img.setBackgroundResource(R.color.new_grty);
weeklist[position] = false;
} else if (!weeklist[position]) {
img.setBackgroundResource(R.color.colorPrimary);
weeklist[position] = true;
}
}
});
return img;
}
示例12: onBindDefaultViewHolder
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, Emojicon item, int position) {
int bound = (int) mContext.getResources().getDimension(R.dimen.space_49);
AbsListView.LayoutParams params = new AbsListView.LayoutParams(bound, bound);
holder.itemView.setLayoutParams(params);
int padding = (int) mContext.getResources().getDimension(
R.dimen.space_10);
holder.itemView.setPadding(padding, padding, padding, padding);
((ImageView) holder.itemView).setImageResource(item.getResId());
}
示例13: createListView
import android.widget.AbsListView; //导入方法依赖的package包/类
private void createListView() {
root = (FrameLayout) inflater.inflate(R.layout.qrh__listview_container,
null);
root.addView(content);
listView.getViewTreeObserver().addOnGlobalLayoutListener(this);
ListViewScrollObserver observer = new ListViewScrollObserver(listView);
// listView.setOnScrollListener(this);
observer.setOnScrollUpAndDownListener(new OnListViewScrollListener() {
@Override
public void onScrollUpDownChanged(int delta, int scrollPosition,
boolean exact) {
onNewScroll(delta);
snap(headerTop == scrollPosition);
}
@Override
public void onScrollIdle() {
QuickReturnHeaderHelper.this.onScrollIdle();
}
});
root.addView(realHeader, realHeaderLayoutParams);
dummyHeader = new View(context);
AbsListView.LayoutParams params = new AbsListView.LayoutParams(
LayoutParams.MATCH_PARENT, headerHeight);
dummyHeader.setLayoutParams(params);
listView.addHeaderView(dummyHeader);
}
示例14: create
import android.widget.AbsListView; //导入方法依赖的package包/类
public static RelativeLayout create(Context context) {
SizeHelper.prepare(context);
RelativeLayout root = new RelativeLayout(context);
root.setId(ResHelper.getIdRes(context, "rl_lv_item_bg"));
AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
SizeHelper.fromPxWidth(95));
root.setLayoutParams(params);
int padding = SizeHelper.fromPxWidth(14);
root.setPadding(padding, padding, padding, padding);
root.setGravity(Gravity.CENTER_VERTICAL);
root.setBackgroundColor(0xffffffff);
AsyncImageView contactImage = new AsyncImageView(context);
contactImage.setId(ResHelper.getIdRes(context, "iv_contact"));
RelativeLayout.LayoutParams contactImageParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(64),
SizeHelper.fromPxWidth(64));
contactImageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
contactImage.setLayoutParams(contactImageParams);
contactImage.setScaleType(ScaleType.FIT_CENTER);
root.addView(contactImage);
LinearLayout wrapper = new LinearLayout(context);
RelativeLayout.LayoutParams wrapperParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
wrapperParams.addRule(RelativeLayout.RIGHT_OF, ResHelper.getIdRes(context, "iv_contact"));
wrapperParams.addRule(RelativeLayout.CENTER_VERTICAL);
wrapperParams.leftMargin = SizeHelper.fromPxWidth(12);
wrapper.setLayoutParams(wrapperParams);
wrapper.setOrientation(LinearLayout.VERTICAL);
root.addView(wrapper);
TextView name = new TextView(context);
name.setId(ResHelper.getIdRes(context, "tv_name"));
LinearLayout.LayoutParams nameParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
name.setLayoutParams(nameParams);
name.setTextColor(0xff333333);
name.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(28));
wrapper.addView(name);
TextView contact = new TextView(context);
contact.setId(ResHelper.getIdRes(context, "tv_contact"));
LinearLayout.LayoutParams contactParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
contact.setLayoutParams(contactParams);
contact.setTextColor(0xff999999);
contact.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
wrapper.addView(contact);
Button add = new Button(context);
add.setId(ResHelper.getIdRes(context, "btn_add"));
RelativeLayout.LayoutParams addParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(92),
SizeHelper.fromPxWidth(46));
addParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addParams.addRule(RelativeLayout.CENTER_VERTICAL);
add.setLayoutParams(addParams);
int resid = ResHelper.getStringRes(context, "smssdk_add_contact");
add.setText(resid);
add.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(22));
add.setTextColor(0xff797979);
//resid = R.getBitmapRes(context, "smssdk_corners_bg");
add.setBackgroundDrawable(DrawableHelper.createCornerBg(context));
add.setPadding(0, 0, 0, 0);
root.addView(add);
return root;
}
示例15: setHeaderLayoutParams
import android.widget.AbsListView; //导入方法依赖的package包/类
public void setHeaderLayoutParams(AbsListView.LayoutParams layoutParams) {
if (this.mHeaderContainer != null) {
this.mHeaderContainer.setLayoutParams(layoutParams);
this.mHeaderHeight = layoutParams.height;
}
}