List of usage examples for android.widget TextView setPadding
@Override public void setPadding(int left, int top, int right, int bottom)
From source file:com.ichi2.anki.NoteEditor.java
private void populateEditFields(String[][] fields, boolean editModelMode) { mFieldsLayoutContainer.removeAllViews(); mEditFields = new LinkedList<FieldEditText>(); // Use custom font if selected from preferences Typeface mCustomTypeface = null;//ww w . j a v a 2 s . c o m SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); String customFont = preferences.getString("browserEditorFont", ""); if (!customFont.equals("")) { mCustomTypeface = AnkiFont.getTypeface(this, customFont); } for (int i = 0; i < fields.length; i++) { View editline_view = getLayoutInflater().inflate(R.layout.card_multimedia_editline, null); FieldEditText newTextbox = (FieldEditText) editline_view.findViewById(R.id.id_note_editText); initFieldEditText(newTextbox, i, fields[i], mCustomTypeface, !editModelMode); TextView label = newTextbox.getLabel(); label.setPadding((int) UIUtils.getDensityAdjustedValue(this, 3.4f), 0, 0, 0); mEditFields.add(newTextbox); ImageButton mediaButton = (ImageButton) editline_view.findViewById(R.id.id_media_button); // Load icons from attributes int[] icons = Themes.getResFromAttr(this, new int[] { R.attr.attachFileImage, R.attr.upDownImage }); // Make the icon change between media icon and switch field icon depending on whether editing note type if (editModelMode && allowFieldRemapping()) { // Allow remapping if originally more than two fields mediaButton.setBackgroundResource(icons[1]); setRemapButtonListener(mediaButton, i); } else if (editModelMode && !allowFieldRemapping()) { mediaButton.setBackgroundResource(0); } else { // Use media editor button if not changing note type mediaButton.setBackgroundResource(icons[0]); setMMButtonListener(mediaButton, i); } mFieldsLayoutContainer.addView(label); mFieldsLayoutContainer.addView(editline_view); } }
From source file:com.jei.widgettest.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)}.//from ww w . ja v a2 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); // Weight ?? . WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mViewPager.getAdapter().getCount()); 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.mickledeals.views.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 w w . j av a 2 s . c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimensionPixelSize(R.dimen.sp_17)); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(Color.argb((int) (MIN_TEXT_ALPHA * 255), 255, 255, 255)); textView.setBackgroundResource(R.drawable.selector_bg); // 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.dtd.thevyshka.Utils.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 ww .j a v a 2s. c o m*/ */ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mTabCount); textView.setGravity(Gravity.CENTER); textView.setTextSize(12);//TODO adapting to all textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(ContextCompat.getColor(context, R.color.white)); 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 / 2, padding, padding / 2, padding); return textView; }
From source file:com.shichai.www.choume.view.tab.SmartTabLayout.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 v a2 s .c o m */ protected TextView createDefaultTabView(CharSequence title) { TextView textView = new TextView(getContext()); textView.setGravity(Gravity.CENTER); textView.setText(title); textView.setTextColor(mTabViewTextColor); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabViewTextSize); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); 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(mTabViewTextAllCaps); } textView.setPadding(mTabViewTextHorizontalPadding, 0, mTabViewTextHorizontalPadding, 0); if (mTabViewTextMinWidth > 0) { textView.setMinWidth(mTabViewTextMinWidth); } return textView; }
From source file:com.keertech.androidnotes.view.tabview.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 . ja v a2 s . c om */ 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)); if (mTabViewTextBackgroundId > 0) { textView.setBackgroundResource(mTabViewTextBackgroundId); } else { 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.socialinfotech.tabbar.smart.SmartTabLayout.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 www. j a v a 2s . co m*/ */ protected TextView createDefaultTabView(CharSequence title) { TextView textView = new TextView(getContext()); textView.setGravity(Gravity.CENTER); textView.setText(title); textView.setTextColor(mTabViewTextColors); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabViewTextSize); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); 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(mTabViewTextAllCaps); } textView.setPadding(mTabViewTextHorizontalPadding, 0, mTabViewTextHorizontalPadding, 0); if (mTabViewTextMinWidth > 0) { textView.setMinWidth(mTabViewTextMinWidth); } return textView; }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** initAddDestButton() * adds the Driving Through button//from w w w . j a v a 2 s. c o m */ protected void initAddDestButton() { //Adds/enables the FrameLayout AddDestFrameLayout = new FrameLayout(this); AddDestFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, 80)); AddDestFrameLayout.setEnabled(true); //Fills the Image Icon ImageView destAddIcon = new ImageView(this); FrameLayout.LayoutParams lliDestIcon = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lliDestIcon.setMargins(dipToPx(10), 0, 0, dipToPx(2)); destAddIcon.setLayoutParams(lliDestIcon); destAddIcon.setPadding(0, dipToPx(5), 0, 0); destAddIcon.setImageResource(R.drawable.google_marker_thumb_mini_through); //Adds the imageicon to the framelayout/enables it AddDestFrameLayout.addView(destAddIcon); //Fills/sets the text TextView destAddText = new TextView(this); FrameLayout.LayoutParams lliDest = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lliDest.setMargins(0, dipToPx(5), 0, 0); destAddText.setLayoutParams(lliDest); destAddText.setPadding(dipToPx(40), dipToPx(6), 0, 0); destAddText.setTextSize(15); destAddText.setText(R.string.mapViewAcField); //Adds the text to the framelayout AddDestFrameLayout.addView(destAddText); //Adds the framelayout to the linearlayout (in the scrollview) sclLayout = (LinearLayout) findViewById(R.id.sclLayout); sclLayout.addView(AddDestFrameLayout, sclLayout.getChildCount()); final Button button = ((Button) findViewById(R.id.btnChooseRoute)); //Adds a clicklistener to the frameLayout AddDestFrameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //Adds a new destination field initDestFrameLayout(); //Moves the button to the bottom setLayoutParams(); if (checkFields() == false) { button.setEnabled(false); button.setText("Show on map"); } else { mapView.getOverlays().clear(); createMap(); } } }); }
From source file:com.landenlabs.all_devtool.TextFragment.java
private void fillLayout() { m_tableLayout.removeAllViews();//from w w w . ja v a 2 s .c o m m_textInfoList.clear(); int minSP = 8; int maxSP = 20; int stepSP = 2; int[] colors = new int[] { 0xffe0e0e0, 0xffffe0e0, 0xffe0ffe0, 0xffe0e0ff }; TableLayout.LayoutParams tableLP = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT); TableRow.LayoutParams rowLP = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.MATCH_PARENT); TextView textView; TableRow tableRow; int textColor = 0xff000000; for (int tfIdx = 0; tfIdx < TextInfo.getCount(); tfIdx++) { Typeface typeface = TextInfo.getTypeface(tfIdx); String typefaceStr = TextInfo.getTypefaceStr(tfIdx); textView = new TextView(m_context); textView.setBackgroundColor(Utils.blend(colors[tfIdx], 0x20000000)); textView.setText(typefaceStr); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); m_tableLayout.addView(textView, tableLP); for (int sizeSP = minSP; sizeSP <= maxSP; sizeSP += stepSP) { tableRow = new TableRow(m_context); tableRow.setBackgroundColor(colors[tfIdx]); tableRow.setTag(Integer.valueOf(m_textInfoList.size())); m_textInfoList.add(new TextInfo(sizeSP, tfIdx)); tableRow.setClickable(true); tableRow.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int idx = (Integer) v.getTag(); showTextDialog(m_textInfoList, idx); } }); textView = new TextView(m_context); textView.setText(String.valueOf(sizeSP) + "sp "); textView.setBackgroundColor(0x20000000); textView.setPadding(8, 0, 8, 0); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); tableRow.addView(textView, rowLP); textView = new TextView(m_context); textView.setText("Normal"); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP); textView.setTypeface(typeface, Typeface.NORMAL); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); tableRow.addView(textView, rowLP); textView = new TextView(m_context); textView.setText("Bold"); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP); textView.setTypeface(typeface, Typeface.BOLD); textView.setPadding(8, 0, 8, 0); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); tableRow.addView(textView, rowLP); textView = new TextView(m_context); textView.setText("Italic"); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP); textView.setTypeface(typeface, Typeface.ITALIC); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); tableRow.addView(textView, rowLP); m_tableLayout.addView(tableRow, tableLP); } } }
From source file:com.wjwu.wpmain.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)}./*from w w w. j a v a 2s. co m*/ */ protected TextView createDefaultTabView(Context context) { float density = getResources().getDisplayMetrics().density; TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, TAB_VIEW_TEXT_SIZE_DP * density); // 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); } ColorStateList csl = context.getResources() .getColorStateList(ThemeAttrTools.getValueOfColorAttr(context, R.attr.c_txt_catalog)); if (csl != null) { textView.setTextColor(csl); } 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 * density); int tabHeight = getResources().getDimensionPixelSize(R.dimen.z_slidingtab_height); int paddingTop = (int) (tabHeight - TAB_VIEW_TEXT_SIZE_DP * density - density) / 2; textView.setPadding(padding, paddingTop, padding, paddingTop); return textView; }