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.andfchat.frontend.activities.ChatScreen.java
@Override public void openAd(Spannable text) { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.popup_description, null); int height = (int) (this.height * 0.8f); int width = (int) (this.width * 0.8f); final PopupWindow descriptionPopup = new FListPopupWindow(layout, width, height); descriptionPopup.showAtLocation(frame, Gravity.CENTER, 0, 0); final TextView descriptionText = (TextView) layout.findViewById(R.id.descriptionText); descriptionText.setText(text);/*from w w w.ja va 2 s. c o m*/ // Enable touching/clicking links in text descriptionText.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java
private static int parseGravity(String value) { int gravity = Gravity.NO_GRAVITY; String[] parts = value.toLowerCase().split("[|]"); for (String part : parts) { switch (part) { case "center": gravity = gravity | Gravity.CENTER; break; case "left": case "textStart": gravity = gravity | Gravity.LEFT; break; case "right": case "textEnd": gravity = gravity | Gravity.RIGHT; break; case "top": gravity = gravity | Gravity.TOP; break; case "bottom": gravity = gravity | Gravity.BOTTOM; break; case "center_horizontal": gravity = gravity | Gravity.CENTER_HORIZONTAL; break; case "center_vertical": gravity = gravity | Gravity.CENTER_VERTICAL; break; }/* w ww . j av a 2 s .c o m*/ } return gravity; }
From source file:com.example.drugsformarinemammals.Dose_Information.java
public void show_dose(ArrayList<Dose_Data> dose, TableLayout dose_table, TableRow dose_data, String drug_name, String group_name, String animal_family, String animal_name, String animal_category, ArrayList<String> notes, ArrayList<String> references, ArrayList<Article_Reference> references_index) { String doseAmount;//from ww w .j a va2 s. c o m String dosePosology; String doseRoute; String doseBookReference; String doseArticleReference; for (int k = 0; k < dose.size(); k++) { if (k > 0) { dose_data = new TableRow(this); } doseAmount = dose.get(k).getAmount(); dosePosology = dose.get(k).getPosology(); doseRoute = dose.get(k).getRoute(); doseBookReference = dose.get(k).getBookReference(); doseArticleReference = dose.get(k).getArticleReference(); //Dose amount data TextView textView_animal_dose_amount = new TextView(this); textView_animal_dose_amount.setText(doseAmount); textView_animal_dose_amount.setSingleLine(false); textView_animal_dose_amount.setTextColor(Color.BLACK); textView_animal_dose_amount.setTextSize(15); textView_animal_dose_amount.setTypeface(Typeface.SANS_SERIF); TableRow.LayoutParams paramsDoseAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseAmount.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_amount, paramsDoseAmount); //Dose posology data TextView textView_animal_dose_posology = new TextView(this); textView_animal_dose_posology.setText(dosePosology); textView_animal_dose_posology.setSingleLine(false); textView_animal_dose_posology.setTextColor(Color.BLACK); textView_animal_dose_posology.setTextSize(15); textView_animal_dose_posology.setTypeface(Typeface.SANS_SERIF); TableRow.LayoutParams paramsDosePosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDosePosology.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Posology")) || screenWidth >= 600) dose_data.addView(textView_animal_dose_posology, paramsDosePosology); //Dose route data TextView textView_animal_dose_route = new TextView(this); textView_animal_dose_route.setText(doseRoute); textView_animal_dose_route.setSingleLine(false); textView_animal_dose_route.setTextColor(Color.BLACK); textView_animal_dose_route.setTextSize(15); textView_animal_dose_route.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600) { TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseRoute.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_route, paramsDoseRoute); } else { TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(30, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseRoute.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_route, paramsDoseRoute); } //Dose reference data TextView textView_animal_dose_reference = new TextView(this); if (!doseBookReference.equals("")) textView_animal_dose_reference.setText(doseBookReference); else if (!doseArticleReference.equals("")) { if (!references.contains(doseArticleReference)) { references.add(references.size(), doseArticleReference); Article_Reference article_reference = new Article_Reference(reference_index, doseArticleReference); references_index.add(references_index.size(), article_reference); reference_index++; } int article_index = references.indexOf(doseArticleReference); textView_animal_dose_reference.setText("(" + references_index.get(article_index).getIndex() + ")"); } textView_animal_dose_reference.setSingleLine(false); textView_animal_dose_reference.setTextColor(Color.BLACK); textView_animal_dose_reference.setTextSize(15); textView_animal_dose_reference.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600) { TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseReference.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_reference, paramsDoseReference); } else { TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(150, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseReference.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_reference, paramsDoseReference); } //Specific note index ArrayList<String> specific_notes = new ArrayList<String>(); specific_notes = helper.read_specific_notes(drug_name, group_name, animal_name, animal_family, animal_category, doseAmount, dosePosology, doseRoute, doseBookReference, doseArticleReference); String index = ""; for (int m = 0; m < specific_notes.size(); m++) { String note = specific_notes.get(m); if (!notes.contains(note)) { notes.add(notes.size(), note); } index += "(" + (notes.indexOf(note) + 1) + ") "; } TextView textView_specific_note_index = new TextView(this); textView_specific_note_index.setText(index); textView_specific_note_index.setSingleLine(false); textView_specific_note_index.setTextColor(Color.BLACK); textView_specific_note_index.setTextSize(15); textView_specific_note_index.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600 && screenWidth < 720) { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(150, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } else if (screenWidth >= 720) { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } else { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(100, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Note")) || screenWidth >= 600) dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } dose_table.addView(dose_data); } }
From source file:com.grass.caishi.cc.activity.SettingUserActivity.java
/** * ?uri??/* ww w . j a va2 s.c om*/ * * @param selectedImage */ private File Uritofile(Uri selectedImage) { File file = null; Cursor cursor = this.getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } file = new File(picturePath); // sendPicture(picturePath); } else { file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } } return file; }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) { final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance() .getCurrent().mShouldShowUiToAcceptTypedWord; final int stripWidth = addToDictionaryStrip.getWidth(); final int width = shouldShowUiToAcceptTypedWord ? stripWidth : stripWidth - mDividerWidth - mPadding * 2; final TextView wordView = (TextView) addToDictionaryStrip.findViewById(R.id.word_to_save); wordView.setTextColor(mColorTypedWord); final int wordWidth = (int) (width * mCenterSuggestionWeight); final CharSequence wordToSave = getEllipsizedText(word, wordWidth, wordView.getPaint()); final float wordScaleX = wordView.getTextScaleX(); wordView.setText(wordToSave);/* w w w . j av a2 s . c o m*/ wordView.setTextScaleX(wordScaleX); setLayoutWeight(wordView, mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT); final int wordVisibility = shouldShowUiToAcceptTypedWord ? View.GONE : View.VISIBLE; wordView.setVisibility(wordVisibility); addToDictionaryStrip.findViewById(R.id.word_to_save_divider).setVisibility(wordVisibility); final Resources res = addToDictionaryStrip.getResources(); final CharSequence hintText; final int hintWidth; final float hintWeight; final TextView hintView = (TextView) addToDictionaryStrip.findViewById(R.id.hint_add_to_dictionary); if (shouldShowUiToAcceptTypedWord) { hintText = res.getText(R.string.hint_add_to_dictionary_without_word); hintWidth = width; hintWeight = 1.0f; hintView.setGravity(Gravity.CENTER); } else { final boolean isRtlLanguage = (ViewCompat .getLayoutDirection(addToDictionaryStrip) == ViewCompat.LAYOUT_DIRECTION_RTL); final String arrow = isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW; final boolean isRtlSystem = SubtypeLocaleUtils.isRtlLanguage(res.getConfiguration().locale); final CharSequence hint = res.getText(R.string.hint_add_to_dictionary); hintText = (isRtlLanguage == isRtlSystem) ? (arrow + hint) : (hint + arrow); hintWidth = width - wordWidth; hintWeight = 1.0f - mCenterSuggestionWeight; hintView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START); } hintView.setTextColor(mColorAutoCorrect); final float hintScaleX = getTextScaleX(hintText, hintWidth, hintView.getPaint()); hintView.setText(hintText); hintView.setTextScaleX(hintScaleX); setLayoutWeight(hintView, hintWeight, ViewGroup.LayoutParams.MATCH_PARENT); }
From source file:com.albedinsky.android.ui.widget.SeekBarWidget.java
/** * Updates current thumb to the specified one. If this seek bar has discrete mode enabled * ({@link #isDiscrete()}), the given thumb will be updated to scaleable drawable if it is not yet. * * @param thumb The new thumb to update to. *//* ww w . j av a2 s . c o m*/ private void updateThumb(Drawable thumb) { this.ensureDecorator(); if (mDecorator.hasPrivateFlag(PFLAG_DISCRETE)) { thumb = mAnimations.makeThumbScaleable(thumb, Gravity.CENTER); } if (mThumb != thumb) { super.setThumb(mThumb = thumb); this.applyThumbTint(); } }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
public void imageSharing(Intent data, String type) { // Get the Uri of the selected file Uri uri = data.getData();/*from www .j a va2 s . com*/ Log.d("imageSharing - type", type + " @"); Log.d("File Uri: ", uri.toString() + " #"); // Get the path String path = null; try { path = getPath(this, uri); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("File Path: ", path + " #"); if (path != null) { String userNum = prefs.getString(stored_user_country_code, "") + prefs.getString(stored_user_mobile_no, ""); String fileName = System.currentTimeMillis() + getFileFormat(path); String msg; if (type.equals("video")) { msg = "VID-" + userNum + "-" + fileName; } else if (type.equals("audio")) { msg = "AUD-" + userNum + "-" + fileName; } else { msg = "IMG-" + userNum + "-" + fileName; } String numb = prefs.getString(stored_chatuserNumber, ""); Log.d("nnumb", numb + " #"); String savefileuri = saveImage(path, fileName, stripNumber(numb)); if (savefileuri.equals(FILE_SIZE_ERROR + "")) { Toast toast = Toast.makeText(getApplicationContext(), "you upload file size is exceed to 30 MB", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else if (!savefileuri.equals("")) { Log.d("msg1", msg + " !"); sendInitmsg(msg, numb); new AsyncTaskUploadFile(savefileuri, msg).execute(); } else { Toast.makeText(getApplicationContext(), "File not found", Toast.LENGTH_SHORT).show(); } } }
From source file:com.stikyhive.stikyhive.ChattingActivity.java
public void clickFileTransfer(View v) { flagMakeOffer = true;// www .j av a 2 s . com showFileChooser(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutTalk.setLayoutParams(params); layoutTalk.setGravity(Gravity.CENTER); flagRecord = false; //loadFileList(); // onCreateDialog(DIALOG_LOAD_FILE); }
From source file:com.mdlive.sav.MDLiveProviderDetails.java
/** * Successful Response Handler for Load Provider Info.Here the Profile image of * the Particular provider will be displayed.Along with that the Provider's * speciality,about the Provider , license and the languages will also be * displayed.Along with this Provider's affilitations will also be displayed * *///from ww w. j a va 2s . c o m private void handleSuccessResponse(JSONObject response) { // DEBUGGING. o.uwechue Log.d("MDLProviderDetails", "*********\nHTTP Response: " + response); try { //Fetch Data From the Services Log.d("Response details", "******************\n*******************\n" + response.toString()); JsonParser parser = new JsonParser(); JsonObject responObj = (JsonObject) parser.parse(response.toString()); JsonObject profileobj = responObj.get("doctor_profile").getAsJsonObject(); JsonObject providerdetObj = profileobj.get("provider_details").getAsJsonObject(); JsonObject appointment_slot = profileobj.get("appointment_slot").getAsJsonObject(); JsonArray available_hour = appointment_slot.get("available_hour").getAsJsonArray(); boolean isDoctorWithPatient = false; LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles); String str_timeslot = ""; /*str_phys_avail_id = "",*/ SharedPreferences sharedpreferences = getSharedPreferences(PreferenceConstants.MDLIVE_USER_PREFERENCES, Context.MODE_PRIVATE); str_Availability_Type = sharedpreferences .getString(PreferenceConstants.PROVIDER_AVAILABILITY_TYPE_PREFERENCES, ""); String str_avail_status = sharedpreferences .getString(PreferenceConstants.PROVIDER_AVAILABILITY_STATUS_PREFERENCES, ""); if (str_avail_status.equalsIgnoreCase("true")) { if (str_Availability_Type.equalsIgnoreCase("video or phone")) { isDoctorAvailableNow = true; } else if (str_Availability_Type.equalsIgnoreCase("phone")) { isDoctorAvailableNow = true; } else if (str_Availability_Type.equalsIgnoreCase("video")) { isDoctorAvailableNow = true; } else if (str_Availability_Type.equalsIgnoreCase("With Patient")) { isDoctorAvailableNow = false; } else { isDoctorAvailableNow = false; } } else { isDoctorAvailableNow = false; } if (layout.getChildCount() > 0) { layout.removeAllViews(); } videoList.clear(); phoneList.clear(); for (int i = 0; i < available_hour.size(); i++) { JsonObject availabilityStatus = available_hour.get(i).getAsJsonObject(); String str_availabilityStatus = ""; if (MdliveUtils.checkJSONResponseHasString(availabilityStatus, "status")) { str_availabilityStatus = availabilityStatus.get("status").getAsString(); if (str_availabilityStatus.equals("Available")) { JsonArray timeSlotArray = availabilityStatus.get("time_slot").getAsJsonArray(); for (int j = 0; j < timeSlotArray.size(); j++) { JsonObject timeSlotObj = timeSlotArray.get(j).getAsJsonObject(); if (MdliveUtils.checkJSONResponseHasString(timeSlotObj, "appointment_type") && MdliveUtils.checkJSONResponseHasString(timeSlotObj, "timeslot")) { str_appointmenttype = timeSlotObj.get("appointment_type").getAsString(); str_timeslot = timeSlotObj.get("timeslot").getAsString(); selectedTimestamp = timeSlotObj.get("timeslot").getAsString(); Log.d("***TIMESLOT***", "****\n****\nTimeslot: [" + selectedTimestamp + "]"); if (MdliveUtils.checkJSONResponseHasString(timeSlotObj, "phys_availability_id")) { str_phys_avail_id = timeSlotObj.get("phys_availability_id").getAsString(); } else { str_phys_avail_id = null; } HashMap<String, String> map = new HashMap<String, String>(); map.put("timeslot", str_timeslot); map.put("phys_id", (str_phys_avail_id == null) ? "" : str_phys_avail_id + ""); map.put("appointment_type", str_appointmenttype); timeSlotListMap.add(map); if (str_timeslot.equals("0")) { if (!str_Availability_Type.equalsIgnoreCase("With Patient")) { final int density = (int) getBaseContext().getResources() .getDisplayMetrics().density; final Button myText = new Button(MDLiveProviderDetails.this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { myText.setElevation(0f); } isDoctorAvailableNow = true; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(4 * density, 4 * density, 4 * density, 4 * density); myText.setLayoutParams(params); myText.setGravity(Gravity.CENTER); myText.setTextColor(Color.WHITE); myText.setTextSize(16); myText.setPadding(8 * density, 4 * density, 8 * density, 4 * density); myText.setBackgroundResource(R.drawable.timeslot_white_rounded_corner); myText.setText("Now"); myText.setBackgroundResource(R.drawable.timeslot_blue_rounded_corner); myText.setClickable(true); previousSelectedTv = myText; if (str_appointmenttype.toLowerCase().contains("video")) { videoList.add(myText); } if (str_appointmenttype.toLowerCase().contains("phone")) { phoneList.add(myText); } LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(4 * density, 4 * density, 4 * density, 4 * density); myText.setLayoutParams(lp); myText.setTag("Now"); defaultNowTextPreferences(myText, str_appointmenttype); selectedTimeslot = true; clickEventForHorizontalText(myText, str_timeslot, str_phys_avail_id); layout.addView(myText); //layout.addView(line, 1); } } else { setHorizontalScrollviewTimeslots(layout, str_timeslot, j, str_phys_avail_id); } } } } else if (str_availabilityStatus.equalsIgnoreCase("With patient")) { isDoctorWithPatient = true; } } } //with patient if (isDoctorWithPatient) { if (layout.getChildCount() >= 1) { // Req Future Appmt enableOrdisableProviderDetails(str_Availability_Type); } else if (layout.getChildCount() < 1) { //Make future appointment onlyWithPatient(); } } /*This is for Status is available and the timeslot is Zero..Remaining all the status were not available.*/ //Available now only else if (isDoctorAvailableNow && layout.getChildCount() < 1) { horizontalscrollview.setVisibility(View.GONE); findViewById(R.id.dateTxtLayout).setVisibility(View.GONE); if (str_Availability_Type.equalsIgnoreCase("video")) { onlyVideo(); } else if (str_Availability_Type.equalsIgnoreCase("video or phone")) { VideoOrPhoneNotAvailable(); } else if (str_Availability_Type.equalsIgnoreCase("phone")) { onlyPhone(); } else if (str_Availability_Type.equalsIgnoreCase("With Patient")) { onlyWithPatient(); } } //Available now and later //Part1 ----> timeslot zero followed by many timeslots else if (isDoctorAvailableNow && layout.getChildCount() >= 1) { enableOrdisableProviderDetails(str_Availability_Type); } //part 2 available ly later //Part2 ----> timeslot not zero followed by many timeslots else if (!isDoctorAvailableNow && layout.getChildCount() >= 1) { availableOnlyLater(str_Availability_Type); } //not available else if (layout.getChildCount() == 0 && str_Availability_Type.equals("not available")) { if (str_appointmenttype.equals("1")) { notAvailable(); } else if (str_appointmenttype.equals("2")) { notAvailable(); } else { notAvailable(); } } //not available else if (layout.getChildCount() == 0) { horizontalscrollview.setVisibility(View.GONE); findViewById(R.id.dateTxtLayout).setVisibility(View.GONE); if (str_Availability_Type.equalsIgnoreCase("video")) { onlyVideo(); } else if (str_Availability_Type.equalsIgnoreCase("video or phone")) { VideoOrPhoneNotAvailable(); } else if (str_Availability_Type.equalsIgnoreCase("phone")) { onlyPhone(); } else if (str_Availability_Type.equalsIgnoreCase("With patient")) { onlyWithPatient(); } else if (str_Availability_Type.equalsIgnoreCase("not available")) { //Make future appointment only notAvailable(); } } setResponseQualificationDetails(providerdetObj, str_Availability_Type); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.stikyhive.stikyhive.ChattingActivity.java
public void clickImageTransfer(View v) { flagMakeOffer = true;/*from w ww . j a v a 2 s .c o m*/ showPhoto(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutTalk.setLayoutParams(params); layoutTalk.setGravity(Gravity.CENTER); flagRecord = false; }