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.infigent.stocksense.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startService(new Intent(this, BackGround.class)); // setSlidingActionBarEnabled(true); Intent n = getIntent();/*from w ww. ja v a 2 s . c om*/ if (getIntent() != null) { Bundle bundle = n.getExtras(); if (bundle != null) { Log.e("ARG", "EXIST"); if (bundle.containsKey("eq")) { Log.e("EQ", "EXIST"); if (bundle.getBoolean("eq")) { Log.e("eq", "true"); Bundle data = new Bundle(); Fragment4 eq = new Fragment4(); mContent = eq; data.putString("q", bundle.getString("q")); data.putString("type", bundle.getString("type")); data.putString("name", bundle.getString("name")); data.putString("f", gId()); eq.setArguments(data); switchContent(eq); } } } } if (savedInstanceState != null) mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent"); if (mContent == null) mContent = new Fragment1(); ScrollView scrollView = new ScrollView(this); LinearLayout l = new LinearLayout(this); TextView one = new TextView(this); one.setText(getResources().getString(R.string.intro)); one.setPadding(0, 0, 0, 20); TextView two = new TextView(this); two.setText("Limited License"); two.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView three = new TextView(this); three.setText(getResources().getString(R.string.l1)); TextView four = new TextView(this); four.setText(getResources().getString(R.string.l2)); four.setPadding(0, 0, 0, 20); TextView five = new TextView(this); five.setText("Disclaimer"); five.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView six = new TextView(this); six.setText(getResources().getString(R.string.disclaimer1)); TextView seven = new TextView(this); seven.setText(getResources().getString(R.string.disclaimer2)); TextView eight = new TextView(this); eight.setText(getResources().getString(R.string.disclaimer3)); eight.setPadding(0, 0, 0, 20); TextView nine = new TextView(this); nine.setText("Liability For Our Services"); nine.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView ten = new TextView(this); ten.setText(getResources().getString(R.string.liability1)); TextView eleven = new TextView(this); eleven.setText(getResources().getString(R.string.liability2)); eleven.setPadding(0, 0, 0, 20); TextView twelve = new TextView(this); twelve.setText("Maintenance And Support"); twelve.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView thirteen = new TextView(this); thirteen.setText(getResources().getString(R.string.ms)); thirteen.setPadding(0, 0, 0, 20); TextView fourteen = new TextView(this); fourteen.setText("Links To Third Party Website"); fourteen.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView fifteen = new TextView(this); fifteen.setText(getResources().getString(R.string.p3)); l.addView(one); l.addView(two); l.addView(three); l.addView(four); l.addView(five); l.addView(six); l.addView(seven); l.addView(eight); l.addView(nine); l.addView(ten); l.addView(eleven); l.addView(twelve); l.addView(thirteen); l.addView(fourteen); l.addView(fifteen); one.setTextColor(getResources().getColor(R.color.White)); two.setTextColor(getResources().getColor(R.color.White)); three.setTextColor(getResources().getColor(R.color.White)); four.setTextColor(getResources().getColor(R.color.White)); five.setTextColor(getResources().getColor(R.color.White)); six.setTextColor(getResources().getColor(R.color.White)); seven.setTextColor(getResources().getColor(R.color.White)); eight.setTextColor(getResources().getColor(R.color.White)); nine.setTextColor(getResources().getColor(R.color.White)); ten.setTextColor(getResources().getColor(R.color.White)); eleven.setTextColor(getResources().getColor(R.color.White)); twelve.setTextColor(getResources().getColor(R.color.White)); thirteen.setTextColor(getResources().getColor(R.color.White)); fourteen.setTextColor(getResources().getColor(R.color.White)); fifteen.setTextColor(getResources().getColor(R.color.White)); l.setOrientation(LinearLayout.VERTICAL); l.setBackgroundColor(getResources().getColor(R.color.bg)); l.setPadding(10, 10, 10, 10); scrollView.addView(l); boolean firstboot = getSharedPreferences("BOOT_PREF", MODE_PRIVATE).getBoolean("firstboot", true); if (firstboot) { LayoutInflater inflater = getLayoutInflater(); View vvv = inflater.inflate(R.layout.alerttitle, null); AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("Terms of Service") .setView(scrollView).setCustomTitle(vvv) .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); getSharedPreferences("BOOT_PREF", MODE_PRIVATE).edit().putBoolean("firstboot", false) .commit(); } }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Close the activity as they have declined the EULA MainActivity.this.finish(); } }).setCancelable(false); builder.create().show(); } ime = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); ActionBar actionBar = getSupportActionBar(); getSupportActionBar().setCustomView(R.layout.search); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); sb = (ImageButton) actionBar.getCustomView().findViewById(R.id.sb); title = (TextView) actionBar.getCustomView().findViewById(R.id.title); sb.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // only will trigger it if no physical keyboard is open search.setVisibility(View.VISIBLE); search.requestFocus(); ime.showSoftInput(search, InputMethodManager.SHOW_IMPLICIT); search.setSelection(search.getText().length()); sb.setVisibility(View.GONE); title.setVisibility(View.GONE); } }); search = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.et); search.setThreshold(2); search.setAdapter(new SuggestionsAdapter(this, search.getText().toString())); search.setSelectAllOnFocus(true); search.clearFocus(); search.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) { String term = parent.getItemAtPosition(pos).toString(); String[] lines = term.split("\\r?\\n"); String name = lines[0]; String code = lines[1].substring(lines[1].indexOf(":") + 1, lines[1].length()).trim(); String type = lines[1].substring(0, lines[1].indexOf(":")); Log.d("DATA", name + " " + type + ":" + code); search.setText(""); if (isNetworkAvailable()) { if (term.replace(" ", "") != null) { Bundle data = new Bundle(); data.putString("q", code); data.putString("type", type); data.putString("name", name); data.putString("f", gId()); Fragment4 eq = new Fragment4(); eq.setArguments(data); Log.d("C", gId() + " frag"); mContent = eq; getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, eq).commit(); getSlidingMenu().showContent(); search.setVisibility(View.GONE); sb.setVisibility(View.VISIBLE); title.setVisibility(View.VISIBLE); ime.hideSoftInputFromWindow(search.getApplicationWindowToken(), 0); } else { Toast.makeText(getApplicationContext(), "Enter a search term!", Toast.LENGTH_LONG).show(); } } else Toast.makeText(getApplicationContext(), "Internet not available", Toast.LENGTH_LONG).show(); } }); search.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { return false; } }); // set the Above View setContentView(R.layout.content_frame); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); AdView mAdView; mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); // set the Behind View setBehindContentView(R.layout.menu_frame); getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new SampleListFragment()).commit(); }
From source file:com.sean.takeastand.ui.MainActivity.java
private void showPauseSettingsDialog() { LayoutInflater inflater = getLayoutInflater(); AlertDialog.Builder builder = new AlertDialog.Builder(this); View dialogView = inflater.inflate(R.layout.dialog_pause, null); TextView title = new TextView(this); title.setPadding(50, 50, 50, 50); title.setTextSize(22);/*from w w w . java 2 s . c o m*/ title.setTextColor(getResources().getColor(android.R.color.holo_blue_light)); title.setText(getResources().getString(R.string.select_pause_type)); builder.setCustomTitle(title); String[] valueSet = new String[pauseTimes.length]; for (int i = 0; i < pauseTimes.length; i++) { valueSet[i] = Integer.toString(pauseTimes[i]); } builder.setView(dialogView); final NumberPicker npPause = (NumberPicker) dialogView.findViewById(R.id.pauseNumberPicker); npPause.setDisplayedValues(valueSet); npPause.setMinValue(0); npPause.setMaxValue(valueSet.length - 1); npPause.setWrapSelectorWheel(false); int initialValue = Utils.getDefaultPauseAmount(this); for (int i = 0; i < pauseTimes.length; i++) { if (initialValue == pauseTimes[i]) { initialValue = i; } } npPause.setValue(initialValue); builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //getValue returns the index number, so need to do some math to correct correct //actual value setDefaultPauseAmount(pauseTimes[npPause.getValue()]); int currentStatus = Utils.getImageStatus(MainActivity.this); if (currentStatus == Constants.NON_SCHEDULE_ALARM_RUNNING || currentStatus == Constants.NON_SCHEDULE_STOOD_UP || currentStatus == Constants.NON_SCHEDULE_TIME_TO_STAND) { pauseUnscheduled(); } else { pauseSchedule(); sendAnalyticsEvent("Paused"); } dialogInterface.dismiss(); } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mPausePlay.setIcon(getResources().getDrawable(R.drawable.ic_action_pause)); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the Disk usage for each disk. * /* w w w . j a v a 2 s .c o m*/ * @return a ScrollView containing a list of AFBarView and AFPieView. */ private View createDiskListDialog() { // use the scroll view to scale ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getDisk_percent_part(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = Double.parseDouble(item.getValue()); String name = item.getName(); LinearLayout row = createTableRow(LinearLayout.HORIZONTAL); AFPieView pieView = createPieView(value); row.addView(pieView); TextView text = new TextView(this); text.setPadding(10, 0, 0, 0); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); text.setText(String.format("%s - %.1f %s used", name, value, "%")); row.addView(text); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the Disk busy for each disk. * /*from www . ja v a 2 s.c o m*/ * @return a ScrollView containing a list of AFBarView and AFPieView. */ private View createDiskBusyListDialog() { ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getDisk_busy(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = 0.0; try { value = Double.parseDouble(item.getValue()); } catch (Exception e) { e.printStackTrace(); continue; } String name = item.getName(); LinearLayout row = createTableRow(LinearLayout.VERTICAL); TextView text = new TextView(this); text.setPadding(5, 0, 0, 0); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); text.setText(name); AFBarView barView = createBarView(value); row.addView(barView); row.addView(text); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }
From source file:com.investallign.controls.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 .jav a 2s . c o m*/ */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) protected TextView createDefaultTabView(Context context) { // FuturaTextView textView = new FuturaTextView(context); LayoutInflater inflater = null; if (inflater == null) inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView textView = (TextView) inflater.inflate(R.layout.sliding_textview, null); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.rachelgrau.rachel.health4theworldstroke.Activities.InfoActivity.java
public void addSubheaderWithText(String text) { LinearLayout ll = (LinearLayout) findViewById(R.id.text_linear_layout); TextView textView = new TextView(this); textView.setTypeface(null, Typeface.BOLD); textView.setText(text);/*from ww w . j av a 2s . c o m*/ textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setPadding(40, 10, 40, 0); textView.setTextSize(16); textView.setBackgroundColor(Color.WHITE); ll.addView(textView); }
From source file:com.vv.androidreview.ui.activites.MainActivity.java
/** * @param indicator1//w w w .j a v a 2 s .c om * @return */ private View getIndicatorView(Indicator indicator1) { View view = LayoutInflater.from(this).inflate(R.layout.tab_indicator, null); TextView indicator = (TextView) view.findViewById(R.id.tab_title); indicator.setText(getString(indicator1.getResName())); indicator.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); Drawable icon = this.getResources().getDrawable(indicator1.getResIcon()); // ICON? // icon.setBounds(0, 0, 75, 75); // indicator.setCompoundDrawables(null,icon,null,null); indicator.setCompoundDrawablePadding(3); indicator.setCompoundDrawablesWithIntrinsicBounds(null, icon, null, null); indicator.setPadding(0, 8, 0, 5); return view; }
From source file:in.animeshpathak.nextbus.NextBusMain.java
/** * Creates the Application Info dialog with clickable links. * // www. ja va2s. c o m * @throws UnsupportedEncodingException * @throws IOException */ private void showVersionInfoDialog() throws UnsupportedEncodingException, IOException { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.app_name) + " " + getString(R.string.version_name)); AssetManager assetManager = getResources().getAssets(); String versionInfoFile = getString(R.string.versioninfo_asset); InputStreamReader reader = new InputStreamReader(assetManager.open(versionInfoFile), "UTF-8"); BufferedReader br = new BufferedReader(reader); StringBuffer sbuf = new StringBuffer(); String line; while ((line = br.readLine()) != null) { sbuf.append(line); sbuf.append("\r\n"); } final ScrollView scroll = new ScrollView(this); final TextView message = new TextView(this); final SpannableString sWlinks = new SpannableString(sbuf.toString()); Linkify.addLinks(sWlinks, Linkify.WEB_URLS); message.setText(sWlinks); message.setMovementMethod(LinkMovementMethod.getInstance()); message.setPadding(15, 15, 15, 15); scroll.addView(message); alertDialog.setView(scroll); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing to do, just dismiss dialog } }); alertDialog.show(); }
From source file:com.example.drugsformarinemammals.Combined_Search.java
private void displayMessage(String messageTitle, String message) { AlertDialog.Builder myalert = new AlertDialog.Builder(this); TextView title = new TextView(this); title.setTypeface(Typeface.SANS_SERIF); title.setTextSize(20);//from w w w. j av a2s . c o m title.setTextColor(getResources().getColor(R.color.blue)); title.setPadding(8, 8, 8, 8); title.setText(messageTitle); title.setGravity(Gravity.CENTER_VERTICAL); LinearLayout layout = new LinearLayout(this); TextView text = new TextView(this); text.setTypeface(Typeface.SANS_SERIF); text.setTextSize(20); text.setPadding(10, 10, 10, 10); text.setText(message); layout.addView(text); myalert.setView(layout); myalert.setCustomTitle(title); myalert.setCancelable(true); myalert.show(); }
From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java
public void getCurrInfo() { tag = 1;/*from w ww .ja v a 2s .co m*/ Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL) .addConverterFactory(GsonConverterFactory.create()).build(); RequestInterface requestInterface = retrofit.create(RequestInterface.class); ServerRequest request = new ServerRequest(); request.setOperation(Constants.GET_SEEKER_PROFILE_OPERATION); request.setUser(user); Call<ServerResponse> response = requestInterface.operation(request); response.enqueue(new Callback<ServerResponse>() { @Override public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) { ServerResponse resp = response.body(); if (resp.getResult().equals(Constants.SUCCESS)) { vehicles = resp.getVehicles(); TableRow tr_head = new TableRow(myContext); tr_head.setBackgroundColor(Color.GRAY); tr_head.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); TextView make = new TextView(myContext); make.setText("MAKE"); make.setTextColor(Color.WHITE); make.setPadding(5, 5, 5, 5); tr_head.addView(make); TextView model = new TextView(myContext); model.setText("MODEL"); model.setTextColor(Color.WHITE); model.setPadding(5, 5, 5, 5); tr_head.addView(model); final TextView license = new TextView(myContext); license.setText("LICENSE PLATE"); license.setTextColor(Color.WHITE); license.setPadding(5, 5, 5, 5); tr_head.addView(license); tl.addView(tr_head, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < vehicles.length; i++) { if (vehicles[i].getDeletedWithHistory() == 1) { continue; } TableRow tr = new TableRow(myContext); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); tr.setTag(tag); tag++; tr.setClickable(true); tr.setOnClickListener(clickListener); TextView v_make = new TextView(myContext); v_make.setText(vehicles[i].getMake()); v_make.setLayoutParams(new TableRow.LayoutParams(300, 150)); tr.addView(v_make); TextView v_model = new TextView(myContext); v_model.setText(vehicles[i].getModel()); v_model.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); tr.addView(v_model); TextView v_license = new TextView(myContext); v_license.setText(vehicles[i].getLicensePlate()); v_license.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); tr.addView(v_license); tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); } } } @Override public void onFailure(Call<ServerResponse> call, Throwable t) { Snackbar.make(rootView, t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show(); } }); }