Java Code Examples for android.widget.listview#setClipToPadding()

The following examples show how to use android.widget.listview#setClipToPadding() . 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: AttitudeHelper.java    From Light-Android-Launcher with GNU General Public License v2.0 6 votes vote down vote up
static ListView applyPadding(ListView listView, Display display) {
    listView.setClipToPadding(false);
    final int displayHeight = display.getHeight();
    int heightViewBasedTopPadding = displayHeight / 6;
    if (getTotalHeightOfListView(listView) < displayHeight - heightViewBasedTopPadding) {
        heightViewBasedTopPadding = (displayHeight / 2) - (getTotalHeightOfListView(listView) / 2);
    }
    listView.setPadding(0, heightViewBasedTopPadding, 0, 50);
    return listView;
}
 
Example 2
Source File: CategoriesFragment.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ListView listView = getListView();
    if (!Utils.isTablet(getActivity())) {
        // TODO ...
        // view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
    }

    if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.categories_list_padding_vertical);
        if (verticalMargin > 0) {
            listView.setClipToPadding(false);
            listView.setPadding(0, verticalMargin, 0, verticalMargin);
        }
    }

    listView.setDrawSelectorOnTop(true);
    // listView.setDivider(getResources().getDrawable(android.R.color.transparent));
    // listView.setDividerHeight(getResources()
    // .getDimensionPixelSize(R.dimen.page_margin_width));

    TypedValue v = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true);
    listView.setSelector(v.resourceId);

    setListAdapter(mAdapter);
}
 
Example 3
Source File: TopicFragment.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ListView listView = getListView();
    View header = LayoutInflater.from(getActivity()).inflate(R.layout.topic_header, listView, false);
    mNotificationDesView = (TextView) header.findViewById(R.id.notification_des);
    mCategoryView = (TextView) header.findViewById(R.id.category);
    mNotificationSpinner = (Spinner) header.findViewById(R.id.notification_spinner);
    mStatusView = (TextView) header.findViewById(R.id.topic_status_view);
    mAdView = (AdView) view.findViewById(R.id.adView);
    mCloseAd = view.findViewById(R.id.close_ad);
    mCloseAd.setOnClickListener(this);
    mAdView.setAdListener(this);
    setupNotificationSpinner();
    listView.addHeaderView(header);
    if (!Utils.isTablet(getActivity())) {
        // TODO ...
        // view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
    }

    if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.topics_list_padding_vertical);
        if (verticalMargin > 0) {
            listView.setClipToPadding(false);
            listView.setPadding(0, verticalMargin, 0, verticalMargin);
        }
    }

    listView.setOnScrollListener(this);
    listView.setDrawSelectorOnTop(true);
    // listView.setDivider(getResources().getDrawable(android.R.color.transparent));
    // listView.setDividerHeight(getResources()
    // .getDimensionPixelSize(R.dimen.page_margin_width));

    TypedValue v = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true);
    listView.setSelector(v.resourceId);

    setListAdapter(mAdapter);
}
 
Example 4
Source File: TopicsListFragment.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ListView listView = getListView();
    if (!Utils.isTablet(getActivity())) {
        // TODO ...
        // view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
    }

    if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.topics_list_padding_vertical);
        if (verticalMargin > 0) {
            listView.setClipToPadding(false);
            listView.setPadding(0, verticalMargin, 0, verticalMargin);
        }
    }

    listView.setOnScrollListener(this);
    listView.setDrawSelectorOnTop(true);
    // listView.setDivider(getResources().getDrawable(android.R.color.transparent));
    // listView.setDividerHeight(getResources()
    // .getDimensionPixelSize(R.dimen.page_margin_width));

    TypedValue v = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true);
    listView.setSelector(v.resourceId);

    setListAdapter(mAdapter);
}
 
Example 5
Source File: SuperListview.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void initAbsListView(View v) {

    View listView = v.findViewById(android.R.id.list);

    if (listView instanceof ListView)
        mList = (ListView) listView;
    else
        throw new IllegalArgumentException("SuperListView works with a List!");


    if (mList != null) {


        mList.setClipToPadding(mClipToPadding);

        //getList().setDivider(mDivider);
        getList().setDividerHeight((int) mDividerHeight);

        mList.setOnScrollListener(this);
        if (mSelector != 0)
            mList.setSelector(mSelector);

        if (mPadding != -1.0f) {
            mList.setPadding(mPadding, mPadding, mPadding, mPadding);
        } else {
            mList.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        }

        if (mScrollbarStyle != -1)
            mList.setScrollBarStyle(mScrollbarStyle);
    }
}
 
Example 6
Source File: PhotoAlbumPickerActivity.java    From KrGallery with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public View createView(Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
    // actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackText(context.getString(R.string.Cancel));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == 1) {
                if (delegate != null) {
                    finishFragment(false);
                    delegate.startPhotoSelectActivity();
                }
            } else if (id == item_photos) {
                refreshShowPic();//刷新照片目录
            } else if (id == item_video) {
                refreshShowVedio();//刷新录像目录
            }
        }
    });


    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(DarkTheme ? 0xff000000 : 0xffffffff);
    //==============videos pick====================
    int res = !singlePhoto && filterMimeTypes.length > 0 ? R.string.PickerVideo : R.string.Album;
    actionBar.setTitle(context.getString(res));
    selectedMode = filterMimeTypes.length > 0 ? 1 : selectedMode;
    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4),
            AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView
            .getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    // layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(R.string.NoPhotos);
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);


    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
        progressView.setVisibility(View.VISIBLE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    return fragmentView;
}