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.ab.view.sliding.AbSlidingTabView2.java
/** * /*from w ww . ja va 2s . co m*/ * ??tab * @throws */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } //? Log.d(TAG, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.easemob.easeui.widget.viewpagerindicator.PagerSlidingTabStrip.java
private void addTextWithIconTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w . j av a2 s.c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setPadding(tabMargin, 0, tabMargin, 0); tab.setTextColor(tabTextColor); // tab.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.btn_tab_mendian_selector, 0, 0); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); addTab(position, tab); }
From source file:dcheungaa.procal.MainActivity.java
@Override public void onWindowFocusChanged(boolean hasFocus) { TextView cursor = (TextView) MainActivity.views.get("cursor"); TextView matrixDisplay = (TextView) MainActivity.views.get("matrixDisplay"); super.onWindowFocusChanged(hasFocus); if (call_load) { call_load = false;/* w w w . j a va2 s .c o m*/ fontWidth = cursor.getWidth(); fontHeight = cursor.getHeight(); cursor.setText(Character.toString((char) 0x258E)); //cursor.setTop(matrixDisplay.getTop()); cursor.setPadding(matrixDisplay.getPaddingLeft(), cursor.getPaddingTop(), cursor.getPaddingRight(), cursor.getPaddingBottom()); cursor.setLeft(matrixDisplay.getLeft()); //CursorHandler.hideCursor(); RelativeLayout cm = (RelativeLayout) findViewById(R.id.content_main); LinearLayout rows = (LinearLayout) findViewById(R.id.llKeyPad); keyPad.KeyPad_resize(cm, rows); int fnBtnHeight = keyPad.btn_rows.get(0).get(0).get_mheight(); System.out.print(Integer.toString(fnBtnHeight)); varPad.resize(fnBtnHeight, fnBtnHeight * 3, svVar); cmdPad.resize(fnBtnHeight, fnBtnHeight * 3, svCmd); constPad.resize(fnBtnHeight, fnBtnHeight * 3, svConst); } }
From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** Presents additional information about a specific assistant. * @return a dynamically generated linear layout */// w w w . ja va 2s .c o m private LinearLayout getServiceDescLayout() { final LinearLayout output = new LinearLayout(this); final RelativeLayout topButtonsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); final Button btnBack = new Button(this); btnBack.setText(R.string.btnAllServices); btnBack.setId(5); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { output.setVisibility(View.GONE); getListView().setVisibility(View.VISIBLE); lblAvAssist.setVisibility(View.VISIBLE); } }); topButtonsLayout.addView(btnBack); final Button btnInvoke = new Button(this); btnInvoke.setText(R.string.btnInvokeLabel); btnInvoke.setId(6); btnInvoke.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new InvocationTask().execute(); } }); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId()); btnInvoke.setLayoutParams(layoutParams); topButtonsLayout.addView(btnInvoke); output.addView(topButtonsLayout); TableLayout serviceInfoTbl = new TableLayout(this); output.addView(serviceInfoTbl); serviceInfoTbl.setColumnShrinkable(1, true); /* FIRST ROW */ TableRow rowServiceName = new TableRow(this); TextView lblServiceName = new TextView(this); lblServiceName.setText(R.string.lblServiceName); lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceName = new TextView(this); txtServiceName.setText(selectedService); txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceName.setPadding(10, 0, 0, 0); rowServiceName.addView(lblServiceName); rowServiceName.addView(txtServiceName); /* SECOND ROW */ TableRow rowServiceDesc = new TableRow(this); TextView lblServiceDesc = new TextView(this); lblServiceDesc.setText(R.string.lblServiceDesc); lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceDesc = new TextView(this); txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceDesc.setPadding(10, 0, 0, 0); List<GateRuntimeParameter> params = null; ServiceInfoForClientArray list = getServices(); for (int i = 0; i < list.getItem().size(); i++) { if (list.getItem().get(i).getServiceName().equals(selectedService)) { txtServiceDesc.setText(list.getItem().get(i).getServiceDescription()); params = list.getItem().get(i).getParams(); break; } } TextView lblParams = new TextView(this); lblParams.setText(R.string.lblServiceParams); lblParams.setTextAppearance(getApplicationContext(), R.style.titleText); output.addView(lblParams); LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout paramsLayout = new LinearLayout(this); paramsLayout.setId(0); if (params.size() > 0) { ScrollView scroll = new ScrollView(this); scroll.setLayoutParams(txtParamsAttrbs); paramsLayout.setOrientation(LinearLayout.VERTICAL); scroll.addView(paramsLayout); for (int j = 0; j < params.size(); j++) { TextView lblParamName = new TextView(this); lblParamName.setText(params.get(j).getParamName()); EditText tview = new EditText(this); tview.setId(1); tview.setText(params.get(j).getDefaultValueString()); LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tview.setLayoutParams(txtViewLayoutParams); paramsLayout.addView(lblParamName); paramsLayout.addView(tview); } output.addView(scroll); } else { TextView lblParamName = new TextView(this); lblParamName.setText(R.string.lblRTParams); output.addView(lblParamName); } rowServiceDesc.addView(lblServiceDesc); rowServiceDesc.addView(txtServiceDesc); serviceInfoTbl.addView(rowServiceName); serviceInfoTbl.addView(rowServiceDesc); output.setOrientation(LinearLayout.VERTICAL); output.setGravity(Gravity.TOP); return output; }
From source file:fr.cph.chicago.adapter.SearchAdapter.java
@Override public final View getView(final int position, View convertView, final ViewGroup parent) { LayoutInflater vi = (LayoutInflater) ChicagoTracker.getAppContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = vi.inflate(R.layout.list_search, null); TextView rounteName = (TextView) convertView.findViewById(R.id.station_name); if (position < mTrains.size()) { final Station station = (Station) getItem(position); Set<TrainLine> lines = station.getLines(); rounteName.setText(station.getName()); LinearLayout stationColorView = (LinearLayout) convertView.findViewById(R.id.station_color); int indice = 0; for (TrainLine tl : lines) { TextView textView = new TextView(mContext); textView.setBackgroundColor(tl.getColor()); textView.setText(" "); textView.setTextSize(mContext.getResources().getDimension(R.dimen.activity_list_station_colors)); stationColorView.addView(textView); if (indice != lines.size()) { textView = new TextView(mContext); textView.setText(""); textView.setPadding(0, 0, (int) mContext.getResources().getDimension(R.dimen.activity_list_station_colors_space), 0);// w w w . j a v a2 s .c o m textView.setTextSize( mContext.getResources().getDimension(R.dimen.activity_list_station_colors)); stationColorView.addView(textView); } indice++; } convertView.setOnClickListener( new FavoritesTrainOnClickListener(mActivity, mContainer, station.getId(), lines)); } else if (position < mTrains.size() + mBuses.size()) { final BusRoute busRoute = (BusRoute) getItem(position); TextView type = (TextView) convertView.findViewById(R.id.train_bus_type); type.setText("B"); rounteName.setText(busRoute.getId() + " " + busRoute.getName()); final TextView loadingTextView = (TextView) convertView.findViewById(R.id.loading_text_view); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { loadingTextView.setVisibility(LinearLayout.VISIBLE); mActivity.startRefreshAnimation(); new DirectionAsyncTask().execute(busRoute, loadingTextView); } }); } else { final BikeStation bikeStation = (BikeStation) getItem(position); TextView type = (TextView) convertView.findViewById(R.id.train_bus_type); type.setText("D"); rounteName.setText(bikeStation.getName()); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ChicagoTracker.getAppContext(), BikeStationActivity.class); Bundle extras = new Bundle(); extras.putParcelable("station", bikeStation); intent.putExtras(extras); mActivity.startActivity(intent); mActivity.overridePendingTransition(R.anim.slide_in, R.anim.slide_out); } }); } return convertView; }
From source file:com.hybunion.member.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { TextView tab = (TextView) tabsContainer.getChildAt(i); tab.setLayoutParams(defaultTabLayoutParams); tab.setBackgroundResource(tabBackgroundResId); if (shouldExpand) { tab.setPadding(0, 0, 0, 0); } else {/* ww w .j ava 2 s . co m*/ tab.setPadding(tabPadding, 0, tabPadding, 0); } tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); } }
From source file:com.anton.gavel.GavelMain.java
public void createDialog(int id) { if (progressDialog != null) { progressDialog.dismiss();/* w w w.ja va 2 s . c om*/ } // handles creation of any dialogs by other actions switch (id) { case DIALOG_PI: //call custom dialog for collecting Personal Info PersonalInfoDialogFragment personalInfoDialog = new PersonalInfoDialogFragment(); personalInfoDialog.setPersonalInfo(mPersonalInfo); personalInfoDialog.show(getSupportFragmentManager(), "PersonalInfoDialogFragment"); break; case DIALOG_ABOUT: //construct a simple dialog to show text //get about text TextView aboutView = new TextView(this); aboutView.setText(R.string.about_text); aboutView.setMovementMethod(LinkMovementMethod.getInstance());//enable links aboutView.setPadding(50, 30, 50, 30); //build dialog AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("About")//title .setView(aboutView)//insert textview from above .setPositiveButton("Done", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setIcon(R.drawable.ic_launcher).create() //build .show(); //display break; case DIALOG_SUBMISSION_ERR: AlertDialog.Builder submissionErrorDialog = new AlertDialog.Builder(this); submissionErrorDialog.setTitle("Submission Error")//title .setMessage("There was a problem submitting your complaint on the City's website.")//insert textview from above .setPositiveButton("Done", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setIcon(R.drawable.ic_launcher).show(); //display break; case DIALOG_OTHER_COMPLAINT: final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); final EditText input = new EditText(this); input.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_CLASS_TEXT); // capitalize letters + seperate words AlertDialog.Builder getComplaintDialog = new AlertDialog.Builder(this); getComplaintDialog.setTitle("Other...").setView(input) .setMessage("Give a categorical title for your complaint:") .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); // add the item to list and make it selected complaintsAdapter.insert(value, 0); complaintSpinner.setSelection(0); complaintsAdapter.notifyDataSetChanged(); addToSubmitValues(value); imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);//hide keyboard dialog.cancel(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);//hide keyboard dialog.cancel(); } }).create(); input.requestFocus(); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);// show keyboard getComplaintDialog.show();//show dialog break; case DIALOG_NO_GEOCODING: AlertDialog.Builder noGeoCoding = new AlertDialog.Builder(this); noGeoCoding.setTitle("Not Available")//title .setMessage( "Your version of Android does not support location-based address lookup. This feature is only supported on Gingerbread and above.")//insert textview from above .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setIcon(R.drawable.ic_launcher).show(); //display break; case DIALOG_INCOMPLETE_PERSONAL_INFORMATION: AlertDialog.Builder incompleteInfo = new AlertDialog.Builder(this); incompleteInfo.setTitle("Incomplete")//title .setMessage( "Your personal information is incomplete. Select 'Edit Personal Information' from the menu and fill in all required fields")//insert textview from above .setPositiveButton("Done", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setIcon(R.drawable.ic_launcher).show(); //display break; case DIALOG_NO_COMPLAINT: AlertDialog.Builder noComplaint = new AlertDialog.Builder(this); noComplaint.setTitle("No Comlaint Specified")//title .setMessage("You must specify a complaint (e.g. barking dog).")//insert textview from above .setPositiveButton("Done", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setIcon(R.drawable.ic_launcher).show(); //display break; case DIALOG_NO_LOCATION: AlertDialog.Builder incompleteComplaint = new AlertDialog.Builder(this); incompleteComplaint.setTitle("No Location Specified")//title .setMessage("You must specify a location (approximate street address) of the complaint.")//insert textview from above .setPositiveButton("Done", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setIcon(R.drawable.ic_launcher).show(); //display } }
From source file:com.slushpupie.deskclock.DeskClock.java
protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_CHANGELOG: AlertDialog.Builder builder = new AlertDialog.Builder(this); // Standard AlertDialog does not support HTML-style links. // So rebuild the ScrollView->TextView with the appropriate // settings and set the view directly. TextView tv = new TextView(this); tv.setPadding(5, 5, 5, 5); tv.setLinksClickable(true);/*from www .j ava 2s .c o m*/ tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setText(R.string.changeLog); tv.setTextAppearance(this, android.R.style.TextAppearance_Medium); ScrollView sv = new ScrollView(this); sv.setPadding(14, 2, 10, 12); sv.addView(tv); builder.setView(sv).setCancelable(false).setTitle(R.string.changeLogTitle) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(DeskClock.this); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("pref_changelog", false); editor.putString("last_changelog", getString(R.string.app_version)); editor.commit(); } }); return builder.create(); default: return null; } }
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java
/** * ??tab./*www .j ava 2 s .co m*/ * * @param tabText the tab text * @param fragment the fragment */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } //? AbLogUtil.d(AbSlidingSmoothTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothTabView.java
/** * ??tab./*from w w w .ja v a 2 s . com*/ * * @param tabText the tab text * @param fragment the fragment */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } //? ESLogUtil.d(ESSlidingSmoothTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }