List of usage examples for android.widget TextView getPaddingRight
public int getPaddingRight()
From source file:angeloid.dreamnarae.SwipeyTabs.java
/** * Calculate the position of the tabs.//from w w w . j a v a2 s . c om * * @param position * the position of the fronted tab * @param tabPositions * the array in which to store the result */ private void calculateTabPosition(int position, int[] tabPositions) { if (mAdapter == null) { return; } final int count = mAdapter.getCount(); if (position >= 0 && position < count) { final int width = getMeasuredWidth(); final View centerTab = getChildAt(position); tabPositions[position] = width / 2 - centerTab.getMeasuredWidth() / 2; for (int i = position - 1; i >= 0; i--) { final TextView tab = (TextView) getChildAt(i); if (i == position - 1) { tabPositions[i] = 0 - tab.getPaddingLeft(); } else { tabPositions[i] = 0 - tab.getMeasuredWidth() - width; } tabPositions[i] = Math.min(tabPositions[i], tabPositions[i + 1] - tab.getMeasuredWidth()); } for (int i = position + 1; i < count; i++) { final TextView tab = (TextView) getChildAt(i); if (i == position + 1) { tabPositions[i] = width - tab.getMeasuredWidth() + tab.getPaddingRight(); } else { tabPositions[i] = width * 2; } final TextView prevTab = (TextView) getChildAt(i - 1); tabPositions[i] = Math.max(tabPositions[i], tabPositions[i - 1] + prevTab.getMeasuredWidth()); } } else { for (int i = 0; i < tabPositions.length; i++) { tabPositions[i] = -1; } } }
From source file:com.ezmeal.swipeytabs.SwipeyTabs.java
/** * Calculate the position of the tabs./* ww w . java 2 s .c o m*/ * * @param position * the position of the fronted tab * @param tabPositions * the array in which to store the result */ private void calculateTabPosition(int position, int[] tabPositions) { if (mAdapter == null) { return; } final int count = mAdapter.getCount(); if (position >= 0 && position < count) { final int width = getMeasuredWidth(); final View centerTab = getChildAt(position); tabPositions[position] = width / 2 - centerTab.getMeasuredWidth() / 2; for (int i = position - 1; i >= 0; i--) { final TextView tab = (TextView) getChildAt(i); if (i == position - 1) { tabPositions[i] = 5 - tab.getPaddingLeft(); } else if (i != 0 && i != count - 1) { tabPositions[i] = 0 - tab.getMeasuredWidth() - width; } tabPositions[i] = Math.min(tabPositions[i], tabPositions[i + 1] - tab.getMeasuredWidth()); } for (int i = position + 1; i < count; i++) { final TextView tab = (TextView) getChildAt(i); if (i == position + 1) { tabPositions[i] = width - tab.getMeasuredWidth() + tab.getPaddingRight() - 5; } else if (i != 0 && i != count - 1) { tabPositions[i] = width * 2; } final TextView prevTab = (TextView) getChildAt(i - 1); tabPositions[i] = Math.max(tabPositions[i], tabPositions[i - 1] + prevTab.getMeasuredWidth()); } /* // make it a circle! if (position == 0) { final TextView tab = (TextView) getChildAt(count - 1); tabPositions[count - 1] = 5 - tab.getPaddingLeft(); } if (position == count - 1) { final TextView tab = (TextView) getChildAt(0); tabPositions[0] = width - tab.getMeasuredWidth() + tab.getPaddingRight() - 5; } */ } else { for (int i = 0; i < tabPositions.length; i++) { tabPositions[i] = -1; } } }
From source file:com.github.irshulx.Components.InputExtensions.java
public void UpdateTextStyle(EditorTextStyle style, TextView editText) { /// String type = getControlType(getActiveView()); try {/*from ww w .java2 s . c o m*/ if (editText == null) { editText = (EditText) editorCore.getActiveView(); } EditorControl tag = editorCore.getControlTag(editText); int pBottom = editText.getPaddingBottom(); int pRight = editText.getPaddingRight(); int pTop = editText.getPaddingTop(); if (isEditorTextStyleHeaders(style)) { updateTextStyle(editText, style); return; } if (isEditorTextStyleContentStyles(style)) { boolean containsHeadertextStyle = containsHeaderTextStyle(tag); if (style == EditorTextStyle.BOLD) { boldifyText(tag, editText, containsHeadertextStyle ? HEADING : CONTENT); } else if (style == EditorTextStyle.ITALIC) { italicizeText(tag, editText, containsHeadertextStyle ? HEADING : CONTENT); } return; } if (style == EditorTextStyle.INDENT) { if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.INDENT)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Delete); editText.setPadding(0, pTop, pRight, pBottom); editText.setTag(tag); } else { tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Insert); editText.setPadding(30, pTop, pRight, pBottom); editText.setTag(tag); } } else if (style == EditorTextStyle.OUTDENT) { if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.INDENT)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Delete); editText.setPadding(0, pTop, pRight, pBottom); editText.setTag(tag); } } else if (style == EditorTextStyle.BLOCKQUOTE) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) editText.getLayoutParams(); if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BLOCKQUOTE)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BLOCKQUOTE, Op.Delete); editText.setPadding(0, pTop, pRight, pBottom); editText.setBackgroundDrawable(ContextCompat.getDrawable(this.editorCore.getContext(), R.drawable.invisible_edit_text)); params.setMargins(0, 0, 0, (int) editorCore.getContext().getResources() .getDimension(R.dimen.edittext_margin_bottom)); } else { float marginExtra = editorCore.getContext().getResources() .getDimension(R.dimen.edittext_margin_bottom) * 1.5f; tag = editorCore.updateTagStyle(tag, EditorTextStyle.BLOCKQUOTE, Op.Insert); editText.setPadding(30, pTop, 30, pBottom); editText.setBackgroundDrawable( editText.getContext().getResources().getDrawable(R.drawable.block_quote_background)); params.setMargins(0, (int) marginExtra, 0, (int) marginExtra); } editText.setTag(tag); } } catch (Exception e) { } }
From source file:com.community.yuequ.bottombar.BottomBar.java
private void updateTitleBottomPadding() { if (tabContainer == null) { return;// w ww . ja v a 2s . c o m } 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;/*from w ww. j av a2 s . c o m*/ } 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 w w w . ja va2 s. c o 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 . java 2 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./* www .j av a 2 s. c om*/ */ 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(); }