Example usage for android.view Gravity CENTER

List of usage examples for android.view Gravity CENTER

Introduction

In this page you can find the example usage for android.view Gravity CENTER.

Prototype

int CENTER

To view the source code for android.view Gravity CENTER.

Click Source Link

Document

Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.

Usage

From source file:com.insthub.O2OMobile.Activity.D3_OrderCommentActivity.java

@Override
public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException {
    if (url.endsWith(ApiInterface.COMMENT_SEND)) {
        ToastView toast = new ToastView(this, getString(R.string.evaluate_success));
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();//from   www  .j  a  v  a  2 s .c  o  m
        Intent intentResult = new Intent();
        intentResult.putExtra(O2OMobileAppConst.ORDERINFO, mCommentModel.publicOrder);
        setResult(Activity.RESULT_OK, intentResult);
        finish();
        Intent intent = new Intent(this, D3_OrderCommentCompleteActivity.class);
        intent.putExtra("order_id", mOrder_info.id);
        startActivity(intent);
    }
}

From source file:android.support.v7.internal.widget.ScrollingTabContainerView.java

private LinearLayoutCompat createTabLayout() {
    final LinearLayoutCompat tabLayout = new LinearLayoutCompat(getContext(), null,
            R.attr.actionBarTabBarStyle);
    tabLayout.setMeasureWithLargestChildEnabled(true);
    tabLayout.setGravity(Gravity.CENTER);
    tabLayout.setLayoutParams(new LinearLayoutCompat.LayoutParams(LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
            LinearLayoutCompat.LayoutParams.MATCH_PARENT));
    return tabLayout;
}

From source file:com.bangqu.eshow.util.ESDialogUtil.java

/**
 * ?.// w w w .ja  v a2s .  c  o  m
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @return
 */
public static ESSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit) {
    return showDialog(view, animEnter, animExit, animPopEnter, animPopExit, Gravity.CENTER, defaultStyle);
}

From source file:cn.org.eshow.framwork.util.AbDialogUtil.java

/**
 * ?./*from  w w w  . j  a  va  2s  . c om*/
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @return
 */
public static AbSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit) {
    return showDialog(view, animEnter, animExit, animPopEnter, animPopExit, Gravity.CENTER, defaultStyle);
}

From source file:com.mobilevangelist.glass.helloworld.GetTheWeatherActivity.java

private Bitmap loadImageFromURL(String getURL) {

    try {/* www  .  j  a  va  2 s  . c  o  m*/
        URL url = new URL(getURL);

        HttpGet httpRequest = null;
        httpRequest = new HttpGet(url.toURI());
        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
        HttpEntity entity = response.getEntity();
        BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
        InputStream input = b_entity.getContent();
        Bitmap bitmap = BitmapFactory.decodeStream(input);
        return bitmap;
    } catch (Exception ex) {

        Toast t2 = Toast.makeText(getApplicationContext(), "Image Loading Failed", Toast.LENGTH_LONG);
        t2.setGravity(Gravity.CENTER, 0, 0);
        t2.show();
        return null;
    }
}

From source file:gr.rambou.secheader.MainActivity.java

private void getHeader(String url) {
    //Create a Listener for our requests
    Response.Listener listener = new Response.Listener<JSONObject>() {
        @Override//from   w  w  w  .j av  a  2  s  .  c o  m
        public void onResponse(JSONObject newjson) {
            //Check if we need to save into database
            CheckBox cb = (CheckBox) findViewById(R.id.checkbox_save);
            if (cb.isChecked()) {
                //We open/create our sqlite database
                DatabaseHandler mydb = new DatabaseHandler(getApplicationContext());

                //Loop over all results
                for (int i = 0; i < newjson.names().length(); i++) {
                    try {
                        //Check if the value is URL and don't insert it into db
                        String value = newjson.names().getString(i).toString();
                        if (!value.equals("URL"))
                            //Add result into database
                            mydb.addResult(newjson.getString("URL"), value,
                                    (newjson.get(newjson.names().getString(i)).equals("Secure")) ? 1 : 0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }
            /*
            for (int i = 0; i < newjson.names().length(); i++) {
            try {
                Log.wtf("LOL", "key = " + newjson.names().getString(i) + " value = " + newjson.get(newjson.names().getString(i)));
            } catch (JSONException e) {
                e.printStackTrace();
            }
            }*/

            //decrease requests value;
            requests--;

            //Update progressBar
            int max = ((ProgressBar) findViewById(R.id.progressBar)).getMax();
            ((ProgressBar) findViewById(R.id.progressBar)).setProgress(max - requests);

            //Check if we finished
            if (requests == 1) {
                //Sending a toast to the user that we got all headers
                Context context = getApplicationContext();
                CharSequence text = "We Got all Headers!!!";
                int duration = Toast.LENGTH_SHORT;
                Toast toast = Toast.makeText(context, text, duration);
                toast.setGravity(Gravity.CENTER | Gravity.CENTER, 0, 0);
                toast.show();
                //Re-Enable Buttons functionality
                (findViewById(R.id.button_scan)).setEnabled(true);
                (findViewById(R.id.checkbox_save)).setEnabled(true);
            }

        }
    };
    //Create an Error Listener for our requests
    Response.ErrorListener errorListener = new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (error.networkResponse != null) {
                Log.v("Error Response code", String.valueOf(error.networkResponse.statusCode));
            }
        }
    };

    // Request a string response from the provided URL.
    JsonObjectRequest stringRequest = new JsonObjectRequest(Request.Method.HEAD, //We only want the headers, although it's similar with GET.
            url, //our url
            listener, //our listener, handling our findings
            errorListener) { //Error Listener to handle errors in requests

        @Override
        protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
            try {
                //We create a JSONObject and add the url address to it.
                org.json.JSONObject f = new JSONObject(response.headers).put("URL", this.getUrl());

                /*We return the headers as a JSONObject which,
                we filter the headers and return the security ones*/
                return Response.success(FilterHeaders(f), HttpHeaderParser.parseCacheHeaders(response));
            } catch (JSONException e) {
                return Response.error(new ParseError(e));
            }
        }

    };

    // Add the request to the RequestQueue.
    queue.add(stringRequest);

}

From source file:com.android.contacts.common.list.ViewPagerTabs.java

private void addTab(CharSequence tabTitle, final int position) {
    View tabView;//w w  w .  jav  a2 s . c o  m
    if (mTabIcons != null && position < mTabIcons.length) {
        View layout = LayoutInflater.from(getContext()).inflate(R.layout.unread_count_tab, null);
        View iconView = layout.findViewById(R.id.icon);
        iconView.setBackgroundResource(mTabIcons[position]);
        iconView.setContentDescription(tabTitle);
        TextView textView = (TextView) layout.findViewById(R.id.count);
        if (mUnreadCounts != null && mUnreadCounts[position] > 0) {
            textView.setText(Integer.toString(mUnreadCounts[position]));
            textView.setVisibility(View.VISIBLE);
            iconView.setContentDescription(
                    getResources().getQuantityString(R.plurals.tab_title_with_unread_items,
                            mUnreadCounts[position], tabTitle.toString(), mUnreadCounts[position]));
        } else {
            textView.setVisibility(View.INVISIBLE);
            iconView.setContentDescription(tabTitle);
        }
        tabView = layout;
    } else {
        final TextView textView = new TextView(getContext());
        textView.setText(tabTitle);
        textView.setBackgroundResource(R.drawable.view_pager_tab_background);

        // Assign various text appearance related attributes to child views.
        if (mTextStyle > 0) {
            textView.setTypeface(textView.getTypeface(), mTextStyle);
        }
        if (mTextSize > 0) {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
        }
        if (mTextColor != null) {
            textView.setTextColor(mTextColor);
        }
        textView.setAllCaps(mTextAllCaps);
        textView.setGravity(Gravity.CENTER);

        tabView = textView;
    }

    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPager.setCurrentItem(getRtlPosition(position));
        }
    });

    tabView.setOnLongClickListener(new OnTabLongClickListener(position));

    tabView.setPadding(mSidePadding, 0, mSidePadding, 0);

    mTabStrip.addView(tabView, position,
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1));

    // Default to the first child being selected
    if (position == 0) {
        mPrevSelected = 0;
        tabView.setSelected(true);
    }
}

From source file:com.bangqu.eshow.util.ESDialogUtil.java

/**
 * ?./* ww w .  j a v  a 2s. co m*/
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @return
 */
public static ESSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, int style) {
    return showDialog(view, animEnter, animExit, animPopEnter, animPopExit, Gravity.CENTER, style);
}

From source file:com.sina.weibo.sdk.widget.LoginButton1.java

/**
 * //from  w w w.  java 2s  .co  m
 *
 * @param attrs XML 
 */
private void loadDefaultStyle(AttributeSet attrs) {
    if (attrs != null && 0 == attrs.getStyleAttribute()) {
        Resources res = getResources();
        this.setBackgroundResource(R.drawable.com_sina_weibo_sdk_button_blue);
        this.setPadding(res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_left),
                res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_top),
                res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_right),
                res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_bottom));
        this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_com_sina_weibo_sdk_logo, 0, 0, 0);
        this.setCompoundDrawablePadding(
                res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_compound_drawable_padding));
        this.setTextColor(res.getColor(R.color.com_sina_weibo_sdk_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                res.getDimension(R.dimen.com_sina_weibo_sdk_loginview_text_size));
        this.setTypeface(Typeface.DEFAULT_BOLD);
        this.setGravity(Gravity.CENTER);
        this.setText(R.string.com_sina_weibo_sdk_login_withweb);
    }
}

From source file:cn.org.eshow.framwork.util.AbDialogUtil.java

/**
 * ?./* w ww.jav a2 s  . c o m*/
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @return
 */
public static AbSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, int style) {
    return showDialog(view, animEnter, animExit, animPopEnter, animPopExit, Gravity.CENTER, style);
}