Java Code Examples for android.widget.AbsListView#LayoutParams

The following examples show how to use android.widget.AbsListView#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: GridViewAdapter.java    From AndroidStarterKit with MIT License 6 votes vote down vote up
@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;
}
 
Example 2
Source File: AlertDialogActivity.java    From Android-skin-support with MIT License 6 votes vote down vote up
@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;
}
 
Example 3
Source File: SplashActivity.java    From Android-skin-support with MIT License 6 votes vote down vote up
@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;
}
 
Example 4
Source File: DragSortListView.java    From android-kernel-tweaker with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 5
Source File: DragSortListView.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 6
Source File: AdpArtists.java    From freemp with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 7
Source File: QuickReturnHeaderHelper.java    From QuickReturnHeader with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 8
Source File: Tab3ListFragment.java    From RefreashTabView with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 9
Source File: TwoDScrollerListview.java    From 2DScroller with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: PinnedHeaderAddressExpandableListView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: AccessibilityTabModelListItem.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: MultiItemRowListAdapter.java    From SimplifyReader with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 13
Source File: ExpandableList1.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: HeaderAdViewView.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 15
Source File: LVRecyclerViewAdapter.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 初始化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);
    }
}
 
Example 16
Source File: MonthAdapter.java    From date_picker_converter with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 17
Source File: DefaultCellView.java    From mCalendar with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 18
Source File: PullToZoomViewEx.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
public void setHeaderLayoutParams(AbsListView.LayoutParams layoutParams) {
    if (mHeaderContainer != null) {
        mHeaderContainer.setLayoutParams(layoutParams);
        mHeaderHeight = layoutParams.height;
    }
}
 
Example 19
Source File: FlexibleSpaceWithImageListViewFragment.java    From Android-ObservableScrollView with Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example 20
Source File: FlexibleSpaceWithImageListViewActivity.java    From Android-ObservableScrollView with Apache License 2.0 4 votes vote down vote up
@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);
}