List of usage examples for android.widget TextView getPaddingLeft
public int getPaddingLeft()
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
public void layoutImportantNotice(final View importantNoticeStrip, final String importantNoticeTitle) { final TextView titleView = (TextView) importantNoticeStrip.findViewById(R.id.important_notice_title); final int width = titleView.getWidth() - titleView.getPaddingLeft() - titleView.getPaddingRight(); titleView.setTextColor(mColorAutoCorrect); titleView.setText(importantNoticeTitle); titleView.setTextScaleX(1.0f); // Reset textScaleX. final float titleScaleX = getTextScaleX(importantNoticeTitle, width, titleView.getPaint()); titleView.setTextScaleX(titleScaleX); }
From source file:com.github.vseguip.sweet.contacts.SweetConflictResolveActivity.java
/** * @param fieldTable// www . ja v a 2 s . c o m * @param nameOfField * @param field */ private void addConflictRow(TableLayout fieldTable, final String nameOfField, final String fieldLocal, final String fieldRemote) { if (mCurrentLocal == null || mCurrentSugar == null) return; // String fieldLocal = mCurrentLocal.get(nameOfField); // String fieldRemote = mCurrentSugar.get(nameOfField); TableRow row = new TableRow(this); final Spinner sourceSelect = new Spinner(this); sourceSelect.setBackgroundResource(R.drawable.black_underline); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, this.getResources().getStringArray(R.array.conflict_sources)); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sourceSelect.setAdapter(spinnerArrayAdapter); // Open the spinner when pressing any of the text fields OnClickListener spinnerOpener = new OnClickListener() { @Override public void onClick(View v) { sourceSelect.performClick(); } }; row.addView(sourceSelect); fieldTable.addView(row); row = new TableRow(this); TextView fieldName = new TextView(this); int stringId = this.getResources().getIdentifier(nameOfField, "string", this.getPackageName()); fieldName.setText(this.getString(stringId)); fieldName.setTextSize(16); fieldName.setPadding(fieldName.getPaddingLeft(), fieldName.getPaddingTop(), fieldName.getPaddingRight() + 10, fieldName.getPaddingBottom()); fieldName.setOnClickListener(spinnerOpener); row.addView(fieldName); final TextView fieldValueLocal = new TextView(this); fieldValueLocal.setText(fieldLocal); fieldValueLocal.setTextSize(16); row.addView(fieldValueLocal); fieldValueLocal.setOnClickListener(spinnerOpener); fieldTable.addView(row); row = new TableRow(this); row.addView(new TextView(this));// add dummy control final TextView fieldValueRemote = new TextView(this); fieldValueRemote.setText(fieldRemote); fieldValueRemote.setTextSize(16); fieldValueRemote.setOnClickListener(spinnerOpener); row.addView(fieldValueRemote); sourceSelect.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); resolvedContacts[mPosResolved].set(nameOfField, fieldLocal); } else { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); resolvedContacts[mPosResolved].set(nameOfField, fieldRemote); } } @Override public void onNothingSelected(AdapterView<?> view) { } }); row.setPadding(row.getLeft(), row.getTop() + 5, row.getRight(), row.getBottom() + 10); // Restore appropiate selections according to resolved contact if (resolvedContacts[mPosResolved].get(nameOfField).equals(fieldLocal)) { sourceSelect.setSelection(0); } else { sourceSelect.setSelection(1); } fieldTable.addView(row); }
From source file:com.community.yuequ.bottombar.BottomBar.java
private void updateTitleBottomPadding() { if (tabContainer == null) { return;/*from w ww . j a v a 2 s . c om*/ } int childCount = getTabCount(); for (int i = 0; i < childCount; i++) { View tab = tabContainer.getChildAt(i); TextView title = (TextView) tab.findViewById(R.id.bb_bottom_bar_title); if (title == null) { continue; } int baseline = title.getBaseline(); int height = title.getHeight(); int paddingInsideTitle = height - baseline; int missingPadding = tenDp - paddingInsideTitle; if (missingPadding > 0) { title.setPadding(title.getPaddingLeft(), title.getPaddingTop(), title.getPaddingRight(), missingPadding + title.getPaddingBottom()); } } }
From source file:bottombar.BottomBar.java
private void updateTitleBottomPadding() { int tabCount = getTabCount(); if (tabContainer == null || tabCount == 0 || !isShiftingMode()) { return;// www .j av a 2 s.com } for (int i = 0; i < tabCount; i++) { BottomBarTab tab = getTabAtPosition(i); TextView title = tab.getTitleView(); if (title == null) { continue; } int baseline = title.getBaseline(); int height = title.getHeight(); int paddingInsideTitle = height - baseline; int missingPadding = tenDp - paddingInsideTitle; if (missingPadding > 0) { title.setPadding(title.getPaddingLeft(), title.getPaddingTop(), title.getPaddingRight(), missingPadding + title.getPaddingBottom()); } } }
From source file:com.roughike.bottombar.BottomBar.java
private void updateTitleBottomPadding() { if (isIconsOnlyMode()) { return;/*from www .ja va2 s . co m*/ } int tabCount = getTabCount(); if (tabContainer == null || tabCount == 0 || !isShiftingMode()) { return; } for (int i = 0; i < tabCount; i++) { BottomBarTab tab = getTabAtPosition(i); TextView title = tab.getTitleView(); if (title == null) { continue; } int baseline = title.getBaseline(); int height = title.getHeight(); int paddingInsideTitle = height - baseline; int missingPadding = tenDp - paddingInsideTitle; if (missingPadding > 0) { title.setPadding(title.getPaddingLeft(), title.getPaddingTop(), title.getPaddingRight(), missingPadding + title.getPaddingBottom()); } } }
From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java
/** * As the name means.//from w w w . j a v a2 s. c o m */ private void buildAddressBar(final Uri path) { if (path == null) return; mViewAddressBar.removeAllViews(); new LoadingDialog<Void, Cursor, Void>(getActivity(), false) { LinearLayout.LayoutParams lpBtnLoc; LinearLayout.LayoutParams lpDivider; LayoutInflater inflater = getLayoutInflater(null); final int dim = getResources().getDimensionPixelSize(R.dimen.afc_5dp); int count = 0; @Override protected void onPreExecute() { super.onPreExecute(); lpBtnLoc = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lpBtnLoc.gravity = Gravity.CENTER; }// onPreExecute() @Override protected Void doInBackground(Void... params) { Cursor cursor = getActivity().getContentResolver().query(path, null, null, null, null); while (cursor != null) { if (cursor.moveToFirst()) { publishProgress(cursor); cursor.close(); } else break; /* * Process the parent directory. */ Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(BaseFile.COLUMN_URI))); cursor = getActivity().getContentResolver() .query(BaseFile.genContentUriApi(uri.getAuthority()).buildUpon() .appendPath(BaseFile.CMD_GET_PARENT) .appendQueryParameter(BaseFile.PARAM_SOURCE, uri.getLastPathSegment()).build(), null, null, null, null); } // while return null; }// doInBackground() @Override protected void onProgressUpdate(Cursor... progress) { /* * Add divider. */ if (mViewAddressBar.getChildCount() > 0) { View divider = inflater.inflate(R.layout.afc_view_locations_divider, null); if (lpDivider == null) { lpDivider = new LinearLayout.LayoutParams(dim, dim); lpDivider.gravity = Gravity.CENTER; lpDivider.setMargins(dim, dim, dim, dim); } mViewAddressBar.addView(divider, 0, lpDivider); } Uri lastUri = Uri.parse(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_URI))); TextView btnLoc = (TextView) inflater.inflate(R.layout.afc_button_location, null); String name = BaseFileProviderUtils.getFileName(progress[0]); btnLoc.setText(TextUtils.isEmpty(name) ? getString(R.string.afc_root) : name); btnLoc.setTag(lastUri); btnLoc.setOnClickListener(mBtnLocationOnClickListener); btnLoc.setOnLongClickListener(mBtnLocationOnLongClickListener); mViewAddressBar.addView(btnLoc, 0, lpBtnLoc); if (count++ == 0) { Rect r = new Rect(); btnLoc.getPaint().getTextBounds(name, 0, name.length(), r); if (r.width() >= getResources().getDimensionPixelSize(R.dimen.afc_button_location_max_width) - btnLoc.getPaddingLeft() - btnLoc.getPaddingRight()) { mTextFullDirName .setText(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_NAME))); mTextFullDirName.setVisibility(View.VISIBLE); } else mTextFullDirName.setVisibility(View.GONE); } // if }// onProgressUpdate() @Override protected void onPostExecute(Void result) { super.onPostExecute(result); /* * Sometimes without delay time, it doesn't work... */ mViewLocationsContainer.postDelayed(new Runnable() { public void run() { mViewLocationsContainer.fullScroll(HorizontalScrollView.FOCUS_RIGHT); }// run() }, DisplayPrefs.DELAY_TIME_FOR_VERY_SHORT_ANIMATION); }// onPostExecute() }.execute(); }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * As the name means./*from w w w . j ava 2s .c o m*/ */ private void buildAddressBar(final Uri path) { if (path == null) return; mViewAddressBar.removeAllViews(); new LoadingDialog<Void, Cursor, Void>(getActivity(), false) { LinearLayout.LayoutParams lpBtnLoc; LinearLayout.LayoutParams lpDivider; LayoutInflater inflater = getLayoutInflater(null); final int dim = getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_5dp); int count = 0; @Override protected void onPreExecute() { super.onPreExecute(); lpBtnLoc = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lpBtnLoc.gravity = Gravity.CENTER; }// onPreExecute() @Override protected Void doInBackground(Void... params) { Cursor cursor = getActivity().getContentResolver().query(path, null, null, null, null); while (cursor != null) { if (cursor.moveToFirst()) { publishProgress(cursor); cursor.close(); } else break; /* * Process the parent directory. */ Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(BaseFile.COLUMN_URI))); cursor = getActivity().getContentResolver() .query(BaseFile.genContentUriApi(uri.getAuthority()).buildUpon() .appendPath(BaseFile.CMD_GET_PARENT) .appendQueryParameter(BaseFile.PARAM_SOURCE, uri.getLastPathSegment()).build(), null, null, null, null); } // while return null; }// doInBackground() @Override protected void onProgressUpdate(Cursor... progress) { /* * Add divider. */ if (mViewAddressBar.getChildCount() > 0) { View divider = inflater.inflate(R.layout.anhuu_f5be488d_view_locations_divider, null); if (lpDivider == null) { lpDivider = new LinearLayout.LayoutParams(dim, dim); lpDivider.gravity = Gravity.CENTER; lpDivider.setMargins(dim, dim, dim, dim); } mViewAddressBar.addView(divider, 0, lpDivider); } Uri lastUri = Uri.parse(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_URI))); TextView btnLoc = (TextView) inflater.inflate(R.layout.anhuu_f5be488d_button_location, null); String name = BaseFileProviderUtils.getFileName(progress[0]); btnLoc.setText(TextUtils.isEmpty(name) ? getString(R.string.anhuu_f5be488d_root) : name); btnLoc.setTag(lastUri); btnLoc.setOnClickListener(mBtnLocationOnClickListener); btnLoc.setOnLongClickListener(mBtnLocationOnLongClickListener); mViewAddressBar.addView(btnLoc, 0, lpBtnLoc); if (count++ == 0) { Rect r = new Rect(); btnLoc.getPaint().getTextBounds(name, 0, name.length(), r); if (r.width() >= getResources() .getDimensionPixelSize(R.dimen.anhuu_f5be488d_button_location_max_width) - btnLoc.getPaddingLeft() - btnLoc.getPaddingRight()) { mTextFullDirName .setText(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_NAME))); mTextFullDirName.setVisibility(View.VISIBLE); } else mTextFullDirName.setVisibility(View.GONE); } // if }// onProgressUpdate() @Override protected void onPostExecute(Void result) { super.onPostExecute(result); /* * Sometimes without delay time, it doesn't work... */ mViewLocationsContainer.postDelayed(new Runnable() { public void run() { mViewLocationsContainer.fullScroll(HorizontalScrollView.FOCUS_RIGHT); }// run() }, Display.DELAY_TIME_FOR_VERY_SHORT_ANIMATION); }// onPostExecute() }.execute(); }