Example usage for android.widget ProgressBar setLayoutParams

List of usage examples for android.widget ProgressBar setLayoutParams

Introduction

In this page you can find the example usage for android.widget ProgressBar setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:Main.java

public static ProgressBar createProgress(Context context) {
    ProgressBar p = new ProgressBar(context);
    p.setIndeterminate(true);/*from w  ww  . j  ava2s  . c o m*/
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(40, 40);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    p.setLayoutParams(lp);
    return p;
}

From source file:Main.java

public static ProgressBar createProgress(final Context context) {
    final ProgressBar p = new ProgressBar(context);
    p.setIndeterminate(true);/*from ww  w .j a  v  a2  s  .  c om*/
    final RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(40, 40);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    p.setLayoutParams(lp);
    return p;
}

From source file:re.neutrino.kanji_assist.dictionary_popup.DictionaryBackgroundTask.java

DictionaryBackgroundTask(DictionaryPopup dictionaryPopup) {
    this.context = dictionaryPopup.getContext();
    this.scrollView = (ScrollView) dictionaryPopup.findViewById(R.id.scrollView);
    this.scrollView.removeAllViews();
    ProgressBar progress = new ProgressBar(this.context);
    progress.setLayoutParams(matchParentLayout);
    this.scrollView.addView(progress);
    this.colorRotator = new ColorRotator();
}

From source file:org.onebusaway.android.report.ui.BaseReportActivity.java

protected void setUpProgressBar() {
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.END;/*w ww. jav a2s .  c om*/

    ProgressBar progressBar = new ProgressBar(this);
    progressBar.setIndeterminate(true);
    progressBar.setVisibility(View.GONE);
    progressBar.setIndeterminate(true);
    progressBar.setLayoutParams(params);
    progressBar.getIndeterminateDrawable().setColorFilter(Color.WHITE,
            android.graphics.PorterDuff.Mode.MULTIPLY);

    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setDisplayShowCustomEnabled(true);
        ab.setCustomView(progressBar);
    }
}

From source file:nkfust.selab.android.explorer.layout.view.PhotoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout fl = new FrameLayout(getActivity());
    ProgressBar pb = new ProgressBar(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER;//from w  w  w .ja v a  2 s  .co  m
    pb.setLayoutParams(params);
    image = new CoustomizedImageView(getActivity());
    image.setMaxZoom(2f);
    image.setDrawingCacheEnabled(false);
    aFetcher.loadImage(path, image);

    fl.addView(pb);
    fl.addView(image);
    return fl;
}

From source file:de.gebatzens.ggvertretungsplan.fragment.RemoteDataFragment.java

public View createLoadingView() {
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setGravity(Gravity.CENTER);//from ww  w.ja  v  a 2 s .c  om

    ProgressBar pb = new ProgressBar(getActivity());
    pb.getIndeterminateDrawable().setColorFilter(GGApp.GG_APP.provider.getColor(), PorterDuff.Mode.SRC_IN);
    pb.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    pb.setVisibility(ProgressBar.VISIBLE);

    l.addView(pb);
    return l;
}

From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java

public View createLoadingView() {
    ScrollView sv = new ScrollView(getActivity());
    sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    sv.setTag("gg_scroll");
    sv.setFillViewport(true);//from w w w .ja  v a 2s  .c  o  m
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setGravity(Gravity.CENTER);

    ProgressBar pb = new ProgressBar(getActivity());
    pb.getIndeterminateDrawable().setColorFilter(SIAApp.SIA_APP.school.getAccentColor(),
            PorterDuff.Mode.SRC_IN);
    pb.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    pb.setVisibility(ProgressBar.VISIBLE);

    l.addView(pb);
    sv.addView(l);
    return sv;
}

From source file:com.googlecode.android_scripting.activity.Main.java

protected void initializeViews() {
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    TextView textview = new TextView(this);
    textview.setText(" PhpForAndroid " + version);
    ImageView imageView = new ImageView(this);
    imageView.setImageDrawable(getResources().getDrawable(R.drawable.pfa));
    layout.addView(imageView);/*from   w  w  w. ja va  2s  . co  m*/
    mButton = new Button(this);
    mAboutButton = new Button(this);
    MarginLayoutParams marginParams = new MarginLayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    final float scale = getResources().getDisplayMetrics().density;
    int marginPixels = (int) (MARGIN_DIP * scale + 0.5f);
    marginParams.setMargins(marginPixels, marginPixels, marginPixels, marginPixels);
    mButton.setLayoutParams(marginParams);
    mAboutButton.setLayoutParams(marginParams);
    layout.addView(textview);
    layout.addView(mButton);
    layout.addView(mAboutButton);

    mProgressLayout = new LinearLayout(this);
    mProgressLayout.setOrientation(LinearLayout.HORIZONTAL);
    mProgressLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mProgressLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);

    LinearLayout bottom = new LinearLayout(this);
    bottom.setOrientation(LinearLayout.HORIZONTAL);
    bottom.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    bottom.setGravity(Gravity.CENTER_VERTICAL);
    mProgressLayout.addView(bottom);

    TextView message = new TextView(this);
    message.setText("   In Progress...");
    message.setTextSize(20);
    message.setTypeface(Typeface.DEFAULT_BOLD);
    message.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    ProgressBar bar = new ProgressBar(this);
    bar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    bottom.addView(bar);
    bottom.addView(message);
    mProgressLayout.setVisibility(View.INVISIBLE);

    layout.addView(mProgressLayout);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setProgressBarIndeterminateVisibility(false);

    setContentView(layout);
}

From source file:com.ymt.demo1.plates.news.FileNoticeFragment.java

protected void initView(View view) {

    /*//from   w w  w .  ja  va 2 s .  c o  m
     *listView 
     */
    listView = (PullToRefreshListView) view.findViewById(R.id.pull_to_refresh_list_view);
    ListView theListView = listView.getRefreshableView();
    testArray = new ArrayList<>();
    ProgressBar progressBar = new ProgressBar(getActivity());
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    progressBar.setLayoutParams(params);
    listView.setEmptyView(progressBar);

    /*
    ??
     */
    summaryAdapter = new NewsSummaryAdapter(getActivity());
    listView.setAdapter(summaryAdapter);
    summaryAdapter.setList(testArray);
    scrollView.setListView(listView); //???listView?

    /*
     *??
     */
    theListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, final View view, final int position, long id) {

            /*
            *???
            */
            String[] actionList = new String[] { "", "?" };
            PopActionUtil popActionUtil = PopActionUtil.getInstance(getActivity());
            actionListener = new PopActionListener() {
                @Override
                public void onAction(String action) {
                    switch (action) {
                    case "":
                        Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT).show();
                        break;
                    case "?":
                        Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT).show();
                        break;
                    default:
                        break;
                    }
                }

                @Override
                public void onDismiss() {

                }
            };

            popActionUtil.setActionListener(actionListener);
            popActionUtil.setActions(actionList);
            final PopupWindow itemPopMenu = popActionUtil.getSimpleTxtPopActionMenu();

            itemPopMenu.showAsDropDown(view, view.getWidth() - 20, -view.getHeight());
            itemPopMenu.update();

            return true;
        }
    });

    /*
    listView   ?
     */
    theListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //
            //todo bug
            Intent intent = new Intent(getActivity(), NewsDetailActivity.class);
            NewsSummary summary = (NewsSummary) (parent.getAdapter()).getItem(position);
            intent.putExtra("summary", summary);
            intent.putExtra("type", "notice");
            startActivity(intent);
        }
    });

    /*
     * 
     */
    listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
        @Override
        public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
            mNews.clear();
            startPosition = 1;
            mQueue.add(summaryRequest(state, start, pagesize));
        }

        @Override
        public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
            startPosition++;
            mQueue.add(summaryRequest(state, start, pagesize));
        }
    });

}

From source file:org.apache.cordova.AndroidChromeClient.java

@Override
/**//from  w w w.  ja v  a 2  s  . co m
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.

        // create the linear layout
        LinearLayout layout = new LinearLayout(this.appView.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(this.appView.getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);

        mVideoProgressView = layout;
    }
    return mVideoProgressView;
}