android.widget.ProgressBar#setPadding ( )源码实例Demo

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

源代码1 项目: Capstone-Project   文件: UserProfileActivity.java
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.findItem(R.id.menu_refresh).setEnabled(!mRefreshing && mRefreshMenuEnabled);
    if (mRefreshing) {
        mMenuItemRefreshActionView = new ProgressBar(this);

        // Make progress bar look at the same place as the original menu item was.
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ScreenUtils.dpToPxInt(getApplicationContext(), 48.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 48.0f));
        mMenuItemRefreshActionView.setLayoutParams(layoutParams);
        mMenuItemRefreshActionView.setPadding(ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f));
    } else {
        mMenuItemRefreshActionView = null;
    }
    menu.findItem(R.id.menu_refresh).setActionView(mMenuItemRefreshActionView);

    return super.onPrepareOptionsMenu(menu);
}
 
源代码2 项目: Capstone-Project   文件: PostDetailsActivity.java
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.findItem(R.id.menu_refresh).setEnabled(!mRefreshing && !mFirstTimeLoading);
    if (mRefreshing) {
        mMenuItemRefreshActionView = new ProgressBar(this);

        // Make progress bar look at the same place as the original menu item was.
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ScreenUtils.dpToPxInt(getApplicationContext(), 48.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 48.0f));
        mMenuItemRefreshActionView.setLayoutParams(layoutParams);
        mMenuItemRefreshActionView.setPadding(ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f));
    } else {
        mMenuItemRefreshActionView = null;
    }
    menu.findItem(R.id.menu_refresh).setActionView(mMenuItemRefreshActionView);

    return super.onPrepareOptionsMenu(menu);
}
 
源代码3 项目: iGap-Android   文件: ViewMaker.java
static View getProgressWaitingItem() {

        ProgressBar cslp_progress_bar_waiting = new ProgressBar(G.context);
        cslp_progress_bar_waiting.setId(R.id.cslp_progress_bar_waiting);
        cslp_progress_bar_waiting.setPadding(i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4));
        cslp_progress_bar_waiting.setVisibility(View.VISIBLE);
        FrameLayout.LayoutParams layout_842 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layout_842.gravity = Gravity.CENTER;
        cslp_progress_bar_waiting.setIndeterminate(true);
        cslp_progress_bar_waiting.setLayoutParams(layout_842);

        return cslp_progress_bar_waiting;
    }
 
源代码4 项目: GankGirl   文件: DefaultTipsHelper.java
public DefaultTipsHelper(Context context, View view) {
    this.mView=view;
    this.mContext=context;
    mLoadingView = new ProgressBar(context);
    mLoadingView.setPadding(0, (int) DensityUtils.dip2px(context, 10),
            0, (int) DensityUtils.dip2px(context, 10));
    mLoadingView.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            (int) DensityUtils.dip2px(context, 40)));
}
 
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (firstVisibleItem + visibleItemCount == totalItemCount && getListView().getFooterViewsCount() == 0) {
        ProgressBar progressBar = new ProgressBar(getActivity());
        progressBar.setLayoutParams(new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT
        ));
        progressBar.setPadding(8, 8, 8, 8);
        getListView().addFooterView(progressBar);
    }
}
 
源代码6 项目: v2ex-daily-android   文件: LoadingAdapter.java
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ProgressBar progressBar = new ProgressBar(mContext);
    int padding = ScreenUtils.dp(mContext, 8);
    progressBar.setPadding(padding, padding, padding, padding);
    return progressBar;
}
 
源代码7 项目: MifareClassicTool   文件: WriteTag.java
/**
 * This method is triggered by {@link #checkTag()} and writes a dump
 * to a tag.
 * @param writeOnPos A map within a map (all with type = Integer).
 * The key of the outer map is the sector number and the value is another
 * map with key = block number and value = write information. The write
 * information must be filtered (by {@link #checkTag()}) return values
 * of {@link MCReader#isWritableOnPositions(HashMap, SparseArray)}.<br />
 * Attention: This method does not any checking. The position and write
 * information must be checked by {@link #checkTag()}.
 * @param keyMap A key map generated by {@link KeyMapCreator}.
 */
private void writeDump(
        final HashMap<Integer, HashMap<Integer, Integer>> writeOnPos,
        final SparseArray<byte[][]> keyMap) {
    // Check for write data.
    if (writeOnPos.size() == 0) {
        // Nothing to write. Exit.
        Toast.makeText(this, R.string.info_nothing_to_write,
                Toast.LENGTH_LONG).show();
        return;
    }

    // Create reader.
    final MCReader reader = Common.checkForTagAndCreateReader(this);
    if (reader == null) {
        return;
    }

    // Display don't remove warning.
    LinearLayout ll = new LinearLayout(this);
    int pad = Common.dpToPx(10);
    ll.setPadding(pad, pad, pad, pad);
    ll.setGravity(Gravity.CENTER);
    ProgressBar progressBar = new ProgressBar(this);
    progressBar.setIndeterminate(true);
    pad = Common.dpToPx(5);
    progressBar.setPadding(0, 0, pad, 0);
    TextView tv = new TextView(this);
    tv.setText(getString(R.string.dialog_wait_write_tag));
    tv.setTextSize(18);
    ll.addView(progressBar);
    ll.addView(tv);
    final AlertDialog warning = new AlertDialog.Builder(this)
        .setTitle(R.string.dialog_wait_write_tag_title)
        .setView(ll)
        .create();
    warning.show();


    // Start writing in new thread.
    final Activity a = this;
    final Handler handler = new Handler();
    new Thread(() -> {
        // Write dump to tag.
        for (int sector : writeOnPos.keySet()) {
            byte[][] keys = keyMap.get(sector);
            for (int block : writeOnPos.get(sector).keySet()) {
                // Select key with write privileges.
                byte writeKey[] = null;
                boolean useAsKeyB = true;
                int wi = writeOnPos.get(sector).get(block);
                if (wi == 1 || wi == 4) {
                    writeKey = keys[0]; // Write with key A.
                    useAsKeyB = false;
                } else if (wi == 2 || wi == 5 || wi == 6) {
                    writeKey = keys[1]; // Write with key B.
                }

                // Write block.
                int result = reader.writeBlock(sector, block,
                        mDumpWithPos.get(sector).get(block),
                        writeKey, useAsKeyB);

                if (result != 0) {
                    // Error. Some error while writing.
                    handler.post(() -> Toast.makeText(a,
                            R.string.info_write_error,
                            Toast.LENGTH_LONG).show());
                    reader.close();
                    warning.cancel();
                    return;
                }
            }
        }
        // Finished writing.
        reader.close();
        warning.cancel();
        handler.post(() -> Toast.makeText(a, R.string.info_write_successful,
                Toast.LENGTH_LONG).show());
        a.finish();
    }).start();
}