List of usage examples for android.view Gravity CENTER
int CENTER
To view the source code for android.view Gravity CENTER.
Click Source Link
From source file:com.google.zxing.client.android.CaptureActivity.java
private void initConView() { mToolView = new ViewToolView(this, mData, toolListener); RelativeLayout.LayoutParams toolParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);/*from w w w . j a v a2 s .co m*/ int top = (int) getResources().getDimension(EUExUtil.getResDimenID("plugin_uexscanner_tool_top")); int left = (int) getResources().getDimension(EUExUtil.getResDimenID("plugin_uexscanner_tool_left")); toolParams.setMargins(left, top, left, 0); mToolView.setId(1); mToolView.setLayoutParams(toolParams); mConRel.addView(mToolView); viewfinderView = new ViewfinderView(this, mData); RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); viewParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); viewfinderView.setLayoutParams(viewParams); mConRel.addView(viewfinderView); mGalleryPic = new ImageView(this); RelativeLayout.LayoutParams picParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); picParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); picParams.addRule(RelativeLayout.BELOW, 1); picParams.setMargins(left, top, left, top); mGalleryPic.setLayoutParams(picParams); mConRel.addView(mGalleryPic); mGalleryPic.setVisibility(View.GONE); mFailText = new TextView(this); RelativeLayout.LayoutParams failTextParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); failTextParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mFailText.setLayoutParams(failTextParams); mFailText.setGravity(Gravity.CENTER); mFailText.setTextColor(Color.WHITE); mFailText.setTextSize(25); mConRel.addView(mFailText); mFailText.setVisibility(View.GONE); mFailText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFailText.setVisibility(View.GONE); mGalleryPic.setVisibility(View.GONE); } }); }
From source file:com.firesoft.member.Activity.C1_PublishOrderActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.c1_publish_order); mFormat = new SimpleDateFormat("yyyy-MM-dd"); tv_xtkz = (TextView) findViewById(R.id.mcard_xtkz); mKzView = (LinearLayout) findViewById(R.id.mcard_xtkz_view); member_no = (EditText) findViewById(R.id.mcard_kh); member_name = (EditText) findViewById(R.id.mcard_xm); mobile_no = (EditText) findViewById(R.id.mcard_phone); mAddComplete = (TextView) findViewById(R.id.c0_publish_button); mcard_jb = (TextView) findViewById(R.id.mcard_jb); mcard_jbid = (TextView) findViewById(R.id.mcard_jb_id); mTime = (TextView) findViewById(R.id.mcard_sr); mShared = getSharedPreferences(MemberAppConst.USERINFO, 0); mMemberModel = new MemberModel(this); mMemberModel.addResponseListener(this); initData();/*from ww w . java 2 s . c o m*/ mcard_jb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(C1_PublishOrderActivity.this, F3_RegionPickActivity.class); intent.putExtra("title", ""); intent.putExtra("str_url", ApiInterface.COMMENT_LIST); intent.putExtra("state", 1); startActivityForResult(intent, 1); overridePendingTransition(R.anim.my_scale_action, R.anim.my_alpha_action); } }); tv_xtkz.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mKzView.getVisibility() == View.GONE) { mKzView.setVisibility(View.VISIBLE); } else { mKzView.setVisibility(View.GONE); /* Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); mKzView.setVisibility(View.GONE); } }; mHandler.sendEmptyMessageDelayed(0, 200);*/ } } }); mAddComplete.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String no = member_no.getText().toString().trim(); String name = member_name.getText().toString(); String phone = mobile_no.getText().toString(); String nShopid = mShared.getString("shopid", "0"); String nShopname = mShared.getString("shopname", ""); if ("".equals(name)) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, "????"); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); member_name.setText(""); member_name.requestFocus(); } else if ("".equals(no)) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, "????"); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); member_no.requestFocus(); } else if ("".equals(phone)) { ToastView toast = new ToastView(C1_PublishOrderActivity.this, "???"); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); mobile_no.requestFocus(); } else { SIMPLE_MEMBER member = new SIMPLE_MEMBER(); member.member_no = no; member.member_name = name; member.mobile_no = phone; member.shopid = nShopid; member.shopname = nShopname; mMemberModel.add(member); CloseKeyBoard(); } } }); }
From source file:com.artech.controls.tabs.SlidingTabLayout.java
@SuppressLint("NewApi") protected void applyDefaultTabViewStyle(TextView textView) { textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); }/*from w w w . j a v a2s . c o m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) textView.getLayoutParams(); lp.width = 0; lp.weight = 1; } }
From source file:com.intel.xdk.device.Device.java
@Override public void initialize(CordovaInterface cordova, final CordovaWebView webView) { super.initialize(cordova, webView); this.activity = cordova.getActivity(); this.webView = webView; //remote site support remoteLayout = new AbsoluteLayout(activity); remoteLayout.setBackgroundColor(Color.BLACK); //hide the remote site display until needed remoteLayout.setVisibility(View.GONE); //create the close button remoteClose = new ImageButton(activity); remoteClose.setBackgroundColor(Color.TRANSPARENT); Drawable remoteCloseImage = null;//from w ww . j av a 2 s . c o m remoteCloseImage = activity.getResources().getDrawable( activity.getResources().getIdentifier("remote_close", "drawable", activity.getPackageName())); File remoteCloseImageFile = new File(activity.getFilesDir(), "_intelxdk/remote_close.png"); if (remoteCloseImageFile.exists()) { remoteCloseImage = (Drawable.createFromPath(remoteCloseImageFile.getAbsolutePath())); } else { remoteCloseImage = (activity.getResources().getDrawable( activity.getResources().getIdentifier("remote_close", "drawable", activity.getPackageName()))); } //set the button image //remoteClose.setImageDrawable(remoteCloseImage); remoteClose.setBackgroundDrawable(remoteCloseImage); //set up the button click action remoteClose.setOnClickListener(new OnClickListener() { public void onClick(View v) { closeRemoteSite(); } }); //add the close button remoteLayout.addView(remoteClose); final ViewGroup parent = (ViewGroup) webView.getEngine().getView().getParent(); activity.runOnUiThread(new Runnable() { public void run() { if (parent != null) { //add layout to activity root layout parent.addView(remoteLayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER)); } } }); //Initialize the orientation. lastOrientation = "unknown"; //Listen to the orientation change. OrientationEventListener listener = new OrientationEventListener(activity) { @Override public void onOrientationChanged(int orientation) { //Log.d("orientation","orientation: " + orientation); String currentOrientation = "unknown"; boolean orientationChanged = false; //int displayOrientation = 0; if (orientation > 345 || orientation < 15) { currentOrientation = "portrait"; displayOrientation = 0; } else if (orientation > 75 && orientation < 105) { currentOrientation = "landscape"; displayOrientation = 90; } else if (orientation > 165 && orientation < 195) { currentOrientation = "portrait"; displayOrientation = 180; } else if (orientation > 255 && orientation < 285) { currentOrientation = "landscape"; displayOrientation = -90; } if (currentOrientation.equals("unknown")) { currentOrientation = lastOrientation; } if (!currentOrientation.equals(lastOrientation)) { orientationChanged = true; Log.d("orientation", "Orientation changes from " + lastOrientation + " to " + currentOrientation + ", current orientation: " + orientation + "."); } if (orientationChanged) { String js = "javascript:try{intel.xdk.device.orientation='" + displayOrientation + "';}catch(e){}var e = document.createEvent('Events');e.initEvent('intel.xdk.device.orientation.change', true, true);e.success=true;e.orientation='" + displayOrientation + "';document.dispatchEvent(e);"; injectJS(js); } lastOrientation = currentOrientation; } }; listener.enable(); registerScreenStatusReceiver(); //cache references to methods for use in injectJS try { evaluateJavascript = webView.getClass().getMethod("evaluateJavascript", String.class, ValueCallback.class); } catch (Exception e) { } try { sendJavascript = webView.getClass().getMethod("sendJavascript", String.class); } catch (Exception e) { } emptyVC = new ValueCallback<String>() { @Override public void onReceiveValue(String s) { } }; }
From source file:acn.android.framework.view.helper.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w ww . jav a 2 s .com*/ */ protected AcnTextView createDefaultTabView(Context context) { AcnTextView textView = new AcnTextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); }*/ int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.firesoft.member.Activity.B0_SigninActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { if (isExit == false) { isExit = true;/* w ww . j av a 2 s . c o m*/ ToastView toast = new ToastView(getApplicationContext(), getString(R.string.exit_again)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); handler.sendEmptyMessageDelayed(0, 3000); return true; } else { if (SESSION.getInstance().uid == 0) { finish(); } else { Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } return false; } } return true; }
From source file:com.alexive.graphicalutils.fragments.RecyclerViewFragment.java
/** * Sets a view to be displayed when the list is empty with optional LayoutParams. * @param view Displayed when the list is empty. * @param params Information about how view's layout in the countainer. *//*from w ww . jav a2 s . co m*/ public void setEmptyView(View view, FrameLayout.LayoutParams params) { emptyView = view; isEmptyViewEmptyText = true; FrameLayout frameLayout = (FrameLayout) getView(); if (frameLayout == null) return; //In order to avoid having more than one emptyViews added to the layout if (frameLayout.getChildCount() > 2) frameLayout.removeViewAt(2); if (this.emptyText != null) frameLayout.findViewById(android.R.id.text1).setVisibility(View.GONE); if (params == null) { params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; } frameLayout.addView(view, 1, params); this.emptyViewAddedToLayout = true; actuallySetEmptyView(); }
From source file:com.aazamnawlakha.eac_android.view.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.// w w w . j a va 2s. co m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(context.getResources().getDimension(R.dimen.dimen_9_sp)); textView.setTypeface(Typeface.DEFAULT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style // textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(40, 20, 50, 20); return textView; }
From source file:com.androidstarterkit.module.widget.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from ww w . ja v a 2 s . com */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:cn.archko.pdf.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.// w w w . java 2 s . com */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding / 2, padding, 2 * padding / 3); return textView; }