Java Code Examples for android.widget.ListView#LayoutParams

The following examples show how to use android.widget.ListView#LayoutParams . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IcsListPopupWindow.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: IcsListPopupWindow.java    From android-apps with MIT License 6 votes vote down vote up
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);
}
 
Example 3
Source File: IcsListPopupWindow.java    From zen4android with MIT License 6 votes vote down vote up
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);
}
 
Example 4
Source File: IcsListPopupWindow.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 5
Source File: IcsListPopupWindow.java    From Libraries-for-Android-Developers with MIT License 6 votes vote down vote up
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);
}
 
Example 6
Source File: ListLayoutAdapter.java    From giffun with Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example 7
Source File: IdentifyTvShowFragment.java    From Mizuu with Apache License 2.0 4 votes vote down vote up
public ListAdapter(Context context) {
    mContext = context;
    inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mImageViewLayoutParams = new ListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
 
Example 8
Source File: IdentifyMovieFragment.java    From Mizuu with Apache License 2.0 4 votes vote down vote up
public ListAdapter(Context context) {
    mContext = context;
    inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mImageViewLayoutParams = new ListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
 
Example 9
Source File: IdentifyTvShowEpisodeFragment.java    From Mizuu with Apache License 2.0 4 votes vote down vote up
public ListAdapter(Context context) {
    mContext = context;
    inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mImageViewLayoutParams = new ListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}