android.widget.ListView.getMeasuredWidth()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中android.widget.ListView.getMeasuredWidth()方法的一些代码示例,展示了ListView.getMeasuredWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListView.getMeasuredWidth()方法的具体详情如下:
包路径:android.widget.ListView
类名称:ListView
方法名:getMeasuredWidth

ListView.getMeasuredWidth介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Bitmap bigbitmap    = Bitmap.createBitmap(listview.getMeasuredWidth(), allitemsheight, Bitmap.Config.ARGB_8888);
Canvas bigcanvas    = new Canvas(bigbitmap);

代码示例来源:origin: arcadefire/nice-spinner

private void measurePopUpDimension() {
  int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
  int heightSpec = MeasureSpec.makeMeasureSpec(getPopUpHeight(), MeasureSpec.AT_MOST);
  listView.measure(widthSpec, heightSpec);
  popupWindow.setWidth(listView.getMeasuredWidth());
  popupWindow.setHeight(listView.getMeasuredHeight() - dropDownListPaddingBottom);
}

代码示例来源:origin: stackoverflow.com

public static void setListViewHeightBasedOnChildren(ListView listView) {
  ListAdapter listAdapter = listView.getAdapter(); 
  int totalHeight = 0;
  int listWidth = listView.getMeasuredWidth();
  for (int i = 0; i < listAdapter.getCount(); i++) {
    View listItem = listAdapter.getView(i, null, listView);
    listItem.measure(
      MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
      MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    totalHeight += listItem.getMeasuredHeight();
  }
  // ...update list height
}

代码示例来源:origin: huazhiyuan2008/ViewToImage

/**
 * ListView转换成bitmap
 *
 * @param listView
 * @return List<Bitmap>
 */
public static List<BitmapWithHeight> getWholeListViewItemsToBitmap(final ListView listView) {
  List<BitmapWithHeight> list = new ArrayList<>();
  if (listView == null || listView.getAdapter() == null) {
    return list;
  }
  ListAdapter adapter = listView.getAdapter();
  int count = adapter.getCount();
  for (int i = 0; i < count; i++) {
    View childView = adapter.getView(i, null, listView);
    list.add(getSimpleViewToBitmap(childView, listView.getMeasuredWidth()));
  }
  return list;
}

代码示例来源:origin: stackoverflow.com

Bitmap bigbitmap    = Bitmap.createBitmap(listview.getMeasuredWidth(), allitemsheight, Bitmap.Config.ARGB_8888);
Canvas bigcanvas    = new Canvas(bigbitmap);

代码示例来源:origin: stackoverflow.com

Bitmap bigbitmap = Bitmap.createBitmap(listview.getMeasuredWidth(), allitemsheight, Bitmap.Config.ARGB_8888);
Canvas bigcanvas = new Canvas(bigbitmap);

代码示例来源:origin: stackoverflow.com

public static void setListViewHeightBasedOnChildren(final ListView listView) {
 listView.post(new Runnable() {
   @Override
   public void run() {
     ListAdapter listAdapter = listView.getAdapter();
     if (listAdapter == null) {
       return;
     }
     int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom();
     int listWidth = listView.getMeasuredWidth();
     for (int i = 0; i < listAdapter.getCount(); i++) {
       View listItem = listAdapter.getView(i, null, listView);
       listItem.measure(
           View.MeasureSpec.makeMeasureSpec(listWidth, View.MeasureSpec.EXACTLY),
           View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
       totalHeight += listItem.getMeasuredHeight();
       Log.d("listItemHeight" + listItem.getMeasuredHeight(), "___________");
     }
     ViewGroup.LayoutParams params = listView.getLayoutParams();
     params.height = (int) ((totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1))));
     listView.setLayoutParams(params);
     listView.requestLayout();
   }
 });
 }

代码示例来源:origin: stackoverflow.com

public static void setListViewHeightBasedOnChildren(final ListView listView) {
     listView.post(new Runnable() {
       @Override
       public void run() {
         ListAdapter listAdapter = listView.getAdapter();
         if (listAdapter == null) {
           return;
         }
         int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom();
         int listWidth = listView.getMeasuredWidth();
     for (int i = 0; i < listAdapter.getCount(); i++) {
           View listItem = listAdapter.getView(i, null, listView);
           listItem.measure(
               View.MeasureSpec.makeMeasureSpec(listWidth, View.MeasureSpec.EXACTLY),
           View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
           totalHeight += listItem.getMeasuredHeight();
           Log.d("listItemHeight " + listItem.getMeasuredHeight(), "********");
         }
         Log.d("totalHeight " + totalHeight, "********");
         ViewGroup.LayoutParams params = listView.getLayoutParams();
         params.height = (int) ((totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1))));
         listView.setLayoutParams(params);
         listView.requestLayout();
       }
     });
   }

相关文章

ListView类方法