下面列出了android.widget.ListView#LayoutParams ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void measureScrapChild(View child, int position, int widthMeasureSpec) {
ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams();
if (p == null) {
p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
child.setLayoutParams(p);
}
//XXX p.viewType = mAdapter.getItemViewType(position);
//XXX p.forceAdd = true;
int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
}
private void measureScrapChild(View child, int position, int widthMeasureSpec) {
ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams();
if (p == null) {
p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
child.setLayoutParams(p);
}
//XXX p.viewType = mAdapter.getItemViewType(position);
//XXX p.forceAdd = true;
int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
}
private void measureScrapChild(View child, int position, int widthMeasureSpec) {
ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams();
if (p == null) {
p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
child.setLayoutParams(p);
}
//XXX p.viewType = mAdapter.getItemViewType(position);
//XXX p.forceAdd = true;
int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
}
private void measureScrapChild(View child, int position, int widthMeasureSpec) {
ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams();
if (p == null) {
p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
child.setLayoutParams(p);
}
//XXX p.viewType = mAdapter.getItemViewType(position);
//XXX p.forceAdd = true;
int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
}
private void measureScrapChild(View child, int position, int widthMeasureSpec) {
ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams();
if (p == null) {
p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
child.setLayoutParams(p);
}
//XXX p.viewType = mAdapter.getItemViewType(position);
//XXX p.forceAdd = true;
int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
FoldersViewHolder holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.list_view_item, parent, false);
ListView.LayoutParams params = (ListView.LayoutParams) convertView.getLayoutParams();
params.height = (int) Utils.convertDpToPixels(72.0f, mContext);
convertView.setLayoutParams(params);
holder = new FoldersViewHolder();
holder.fileFolderIcon = convertView.findViewById(R.id.listViewLeftIcon);
holder.fileFolderSizeText = convertView.findViewById(R.id.listViewSubText);
holder.fileFolderNameText = convertView.findViewById(R.id.listViewTitleText);
if (!mFileBrowserView.shouldShowItemSizes()) {
//Hide the item size TextViews.
((View) holder.fileFolderSizeText.getParent()).setVisibility(View.GONE);
RelativeLayout.LayoutParams titleParams = (RelativeLayout.LayoutParams)
holder.fileFolderNameText.getLayoutParams();
titleParams.addRule(RelativeLayout.CENTER_VERTICAL);
holder.fileFolderNameText.setLayoutParams(titleParams);
}
/* if (!mFileBrowserView.shouldShowOverflowMenus()) {
//Hide the overflow menus.
holder.overflowButton.setVisibility(View.GONE);
} else {
holder.overflowButton.setImageResource(R.mipmap.ic_action_overflow_universal);
holder.overflowButton.setFocusable(false);
holder.overflowButton.setFocusableInTouchMode(false);
holder.overflowButton.setOnClickListener(overflowClickListener);
}*/
//Hide the icon if we have to.
if (!mFileBrowserView.shouldShowItemIcons())
holder.fileFolderIcon.setVisibility(View.GONE);
else
holder.fileFolderIcon.setVisibility(View.VISIBLE);
convertView.setTag(holder);
} else {
holder = (FoldersViewHolder) convertView.getTag();
}
holder.fileFolderNameText.setText(getNamesList().get(position));
holder.fileFolderSizeText.setText(getSizesList().get(position));
/*
* Set the icon based on whether the item is a folder or a file.
* Also make sure to set the type of the item as a tag for this
* row.
*/
if (mFileBrowserView.shouldShowItemIcons()) {
if (getTypesList().get(position) == FileBrowserEngine.FOLDER) {
holder.fileFolderIcon.setImageResource(R.mipmap.icon_folderblue);
convertView.setTag(R.string.type, FileBrowserEngine.FOLDER);
} else if (getTypesList().get(position) == FileBrowserEngine.FILE_AUDIO) {
holder.fileFolderIcon.setImageResource(R.mipmap.icon_mp3);
convertView.setTag(R.string.type, FileBrowserEngine.FILE_AUDIO);
} else if (getTypesList().get(position) == FileBrowserEngine.FILE_PICTURE) {
Glide.with(mContext)
.load(getPathsList().get(position))
.asBitmap()
.placeholder(R.mipmap.icon_png)
.into(holder.fileFolderIcon);
convertView.setTag(R.string.type, FileBrowserEngine.FILE_PICTURE);
} else if (getTypesList().get(position) == FileBrowserEngine.FILE_VIDEO) {
holder.fileFolderIcon.setImageResource(R.mipmap.icon_avi);
convertView.setTag(R.string.type, FileBrowserEngine.FILE_VIDEO);
} else {
holder.fileFolderIcon.setImageResource(R.mipmap.icon_default);
convertView.setTag(R.string.type, FileBrowserEngine.FILE_GENERIC);
}
}
/*
* We're gonna need a way to keep track of the file/folder path of each row.
* We'll set the path as the row view's tag.
*/
convertView.setTag(R.string.path, getPathsList().get(position));
return convertView;
}
public ListAdapter(Context context) {
mContext = context;
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mImageViewLayoutParams = new ListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
public ListAdapter(Context context) {
mContext = context;
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mImageViewLayoutParams = new ListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
public ListAdapter(Context context) {
mContext = context;
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mImageViewLayoutParams = new ListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}