android.widget.AbsListView#LayoutParams ( )源码实例Demo

下面列出了android.widget.AbsListView#LayoutParams ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AndroidStarterKit   文件: GridViewAdapter.java
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  AndroidPlatform platform = (AndroidPlatform) getItem(position);

  ViewHolder viewHolder;

  if (convertView == null) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = inflater.inflate(R.layout.layout_grid_item, parent, false);

    ((AbsListView.LayoutParams) convertView.getLayoutParams()).height = columnWidth;

    viewHolder = new ViewHolder();
    viewHolder.img = (ImageView) convertView.findViewById(R.id.cell_img);
    viewHolder.txt = (TextView) convertView.findViewById(R.id.cell_txt);
    convertView.setTag(viewHolder);
  } else {
    viewHolder = (ViewHolder) convertView.getTag();
  }

  Glide.with(context).load(platform.getLogoUrl()).into(viewHolder.img);
  viewHolder.txt.setText(platform.getVerCode());

  return convertView;
}
 
源代码2 项目: freemp   文件: AdpArtists.java
public AdpArtists(Activity activity, ArrayList<ClsTrack> data) {
    this.data = data;
    this.activity = activity;

    listAq = new AQuery(activity);

    int iDisplayWidth = Math.max(320, PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getInt("screenWidth", 800));
    int numColumns = (int) (iDisplayWidth / 310);
    if (numColumns == 0) numColumns = 1;
    width = (iDisplayWidth / numColumns);
    layoutParams = new AbsListView.LayoutParams(width, width);

    fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setDuration(300);
    fadeIn.setInterpolator(new DecelerateInterpolator());
}
 
源代码3 项目: onpc   文件: DragSortListView.java
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);
}
 
源代码4 项目: android-kernel-tweaker   文件: DragSortListView.java
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);
}
 
源代码5 项目: Android-skin-support   文件: SplashActivity.java
@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;
}
 
@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(AlertDialogActivity.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;
}
 
源代码7 项目: mCalendar   文件: DefaultCellView.java
private void initLayout(){
    matchParentParams = new AbsListView.LayoutParams((int) CellConfig.cellWidth, (int) CellConfig.cellHeight);
    this.setLayoutParams(matchParentParams);
    this.setOrientation(VERTICAL);
    textView = new TextView(getContext());
    textView.setGravity(Gravity.CENTER);
    textView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, (float) 1.0));
    this.addView(textView);
}
 
/**
 * 初始化cell的size
 *
 * @param cell
 * @param position
 */
void initCellSize( UDLuaTable cell,  int position) {
     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);
    }
}
 
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);
}
 
源代码10 项目: RefreashTabView   文件: Tab3ListFragment.java
private void listViewAddHeader() {
    placeHolderView = new LinearLayout(getActivity());
    AbsListView.LayoutParams params = new LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, scrollTabHolder
            .headerHeight());
    placeHolderView.setLayoutParams(params);
    listView.getRefreshableView().addHeaderView(placeHolderView);
}
 
源代码11 项目: 2DScroller   文件: TwoDScrollerListview.java
/**
 * To end list at center.
 * 
 * @param context
 * 					{@link Context}.
 */
public void endListAtCenter(Context context) {
	View dummyFooter = new View(context);
	AbsListView.LayoutParams dummyFooterParams = new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, (displayHeight/2 - 70)); /////
	dummyFooter.setBackgroundColor(Color.TRANSPARENT);
	dummyFooter.setLayoutParams(dummyFooterParams);
	addFooterView(dummyFooter);
}
 
private void initHeaderView(Context context) {
	inflater = LayoutInflater.from(context);
	headerView = inflater.inflate(R.layout.list_item_address_group, null);
	AbsListView.LayoutParams lp = new LayoutParams(
			AbsListView.LayoutParams.MATCH_PARENT,
			AbsListView.LayoutParams.WRAP_CONTENT);
	headerView.setLayoutParams(lp);
	this.setPinnedHeaderView(headerView);
}
 
源代码13 项目: 365browser   文件: AccessibilityTabModelListItem.java
/**
 * This call is exposed for the benefit of the animators.
 *
 * @param height The height of the current view.
 */
@SuppressLint("AnimatorKeep")
@UsedByReflection("")
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);
}
 
源代码14 项目: SimplifyReader   文件: MultiItemRowListAdapter.java
public MultiItemRowListAdapter(Context context, ListAdapter adapter, int itemsPerRow, int cellSpacing) {
    if (itemsPerRow <= 0) {
        throw new IllegalArgumentException("Number of items per row must be positive");
    }
    mContextReference = new WeakReference<Context>(context);
    mAdapter = adapter;
    mItemsPerRow = itemsPerRow;
    mCellSpacing = cellSpacing;

    mItemLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT);
    mItemLayoutParams.setMargins(cellSpacing, cellSpacing, 0, 0);
    mItemLayoutParams.weight = 1;
    mRowLayoutParams = new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
}
 
源代码15 项目: codeexamples-android   文件: ExpandableList1.java
public TextView getGenericView() {
    // Layout parameters for the ExpandableListView
    AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, 64);

    TextView textView = new TextView(ExpandableList1.this);
    textView.setLayoutParams(lp);
    // Center the text vertically
    textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    // Set the text starting position
    textView.setPadding(36, 0, 0, 0);
    return textView;
}
 
private ImageView createImageView(String url) {
    ImageView imageView = new ImageView(mContext);
    AbsListView.LayoutParams params = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(params);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    mImageManager.loadUrlImage(url, imageView);
    return imageView;
}
 
源代码17 项目: date_picker_converter   文件: MonthAdapter.java
@Override
@NonNull
public MonthViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    MonthView v = createMonthView(parent.getContext());
    // Set up the new view
    AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.MATCH_PARENT);
    v.setLayoutParams(params);
    v.setClickable(true);
    v.setOnDayClickListener(this);

    return new MonthViewHolder(v);
}
 
源代码18 项目: Ticket-Analysis   文件: PullToZoomViewEx.java
public void setHeaderLayoutParams(AbsListView.LayoutParams layoutParams) {
    if (mHeaderContainer != null) {
        mHeaderContainer.setLayoutParams(layoutParams);
        mHeaderHeight = layoutParams.height;
    }
}
 
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_flexiblespacewithimagelistview, container, false);

    final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    // Set padding view for ListView. This is the flexible space.
    View paddingView = new View(getActivity());
    final int flexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
            flexibleSpaceImageHeight);
    paddingView.setLayoutParams(lp);

    // This is required to disable header's list selector effect
    paddingView.setClickable(true);

    listView.addHeaderView(paddingView);
    setDummyData(listView);
    // TouchInterceptionViewGroup should be a parent view other than ViewPager.
    // This is a workaround for the issue #117:
    // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
    listView.setTouchInterceptionViewGroup((ViewGroup) view.findViewById(R.id.fragment_root));

    // Scroll to the specified offset after layout
    Bundle args = getArguments();
    if (args != null && args.containsKey(ARG_SCROLL_Y)) {
        final int scrollY = args.getInt(ARG_SCROLL_Y, 0);
        ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() {
            @SuppressLint("NewApi")
            @Override
            public void run() {
                int offset = scrollY % flexibleSpaceImageHeight;
                listView.setSelectionFromTop(0, -offset);
            }
        });
        updateFlexibleSpace(scrollY, view);
    } else {
        updateFlexibleSpace(0, view);
    }

    listView.setScrollViewCallbacks(this);

    updateFlexibleSpace(0, view);

    return view;
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flexiblespacewithimagelistview);

    mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mFlexibleSpaceShowFabOffset = getResources().getDimensionPixelSize(R.dimen.flexible_space_show_fab_offset);
    mActionBarSize = getActionBarSize();
    mImageView = findViewById(R.id.image);
    mOverlayView = findViewById(R.id.overlay);
    ObservableListView listView = (ObservableListView) findViewById(R.id.list);
    listView.setScrollViewCallbacks(this);

    // Set padding view for ListView. This is the flexible space.
    View paddingView = new View(this);
    AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
            mFlexibleSpaceImageHeight);
    paddingView.setLayoutParams(lp);

    // This is required to disable header's list selector effect
    paddingView.setClickable(true);

    listView.addHeaderView(paddingView);
    setDummyData(listView);
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setText(getTitle());
    setTitle(null);
    mFab = findViewById(R.id.fab);
    mFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(FlexibleSpaceWithImageListViewActivity.this, "FAB is clicked", Toast.LENGTH_SHORT).show();
        }
    });
    mFabMargin = getResources().getDimensionPixelSize(R.dimen.margin_standard);
    ViewHelper.setScaleX(mFab, 0);
    ViewHelper.setScaleY(mFab, 0);

    // mListBackgroundView makes ListView's background except header view.
    mListBackgroundView = findViewById(R.id.list_background);
}