Example usage for android.webkit WebSettings setTextSize

List of usage examples for android.webkit WebSettings setTextSize

Introduction

In this page you can find the example usage for android.webkit WebSettings setTextSize.

Prototype

@Deprecated
public synchronized void setTextSize(TextSize t) 

Source Link

Document

Sets the text size of the page.

Usage

From source file:system.info.reader.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    resolutions = Properties.resolution(dm);
    Properties.resolution = resolutions[0] + "*" + resolutions[1];
    int tabHeight = 30, tabWidth = 80;
    if (dm.widthPixels >= 480) {
        tabHeight = 40;//  w w  w. ja  v a2 s.  com
        tabWidth = 120;
    }

    tabHost = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.main, tabHost.getTabContentView(), true);
    tabHost.addTab(
            tabHost.newTabSpec("tab1").setIndicator(getString(R.string.brief)).setContent(R.id.PropertyList));
    tabHost.addTab(
            tabHost.newTabSpec("tab2").setIndicator(getString(R.string.online)).setContent(R.id.ViewServer));
    tabHost.addTab(
            tabHost.newTabSpec("tab3").setIndicator(getString(R.string.apps)).setContent(R.id.sViewApps));
    tabHost.addTab(
            tabHost.newTabSpec("tab4").setIndicator(getString(R.string.process)).setContent(R.id.sViewProcess));
    tabHost.addTab(tabHost.newTabSpec("tab5").setIndicator("Services").setContent(R.id.sViewCpu));
    tabHost.addTab(tabHost.newTabSpec("tab6").setIndicator("Tasks").setContent(R.id.sViewMem));
    //tabHost.addTab(tabHost.newTabSpec("tab7")
    //        .setIndicator("Vending")
    //        .setContent(R.id.sViewDisk));
    AppsText = (TextView) findViewById(R.id.TextViewApps);
    ProcessText = (TextView) findViewById(R.id.TextViewProcess);
    ServiceText = (TextView) findViewById(R.id.TextViewCpu);
    TaskText = (TextView) findViewById(R.id.TextViewMem);

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(tabWidth, tabHeight);
    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++)
        tabHost.getTabWidget().getChildAt(i).setLayoutParams(lp);

    properList = (ListView) findViewById(R.id.PropertyList);
    Properties.properListItem = new ArrayList<HashMap<String, Object>>();
    properListItemAdapter = new SimpleAdapter(this, Properties.properListItem, R.layout.property_list,
            new String[] { "ItemTitle", "ItemText" }, new int[] { R.id.ItemTitle, R.id.ItemText });
    properList.setAdapter(properListItemAdapter);
    properList.setOnItemClickListener(mpropertyCL);

    //will support app list later
    //appList = (ListView)findViewById(R.id.AppList);
    //Properties.appListItem = new ArrayList<HashMap<String, Object>>();  
    //SimpleAdapter appListItemAdapter = new SimpleAdapter(this, Properties.appListItem,   
    //             R.layout.app_list,  
    //             new String[] {"ItemTitle", "ItemText"},   
    //             new int[] {R.id.ItemTitle, R.id.ItemText}  
    //         );  
    //appList.setAdapter(appListItemAdapter);

    serverWeb = (WebView) findViewById(R.id.ViewServer);
    WebSettings webSettings = serverWeb.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setUserAgentString("sys.info.trial" + versionCode);
    webSettings.setTextSize(WebSettings.TextSize.SMALLER);
    serverWeb.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;//this will not launch browser when redirect.
        }

        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }
    });

    PackageManager pm = getPackageManager();
    try {
        PackageInfo pi = pm.getPackageInfo("sys.info.trial", 0);
        version = "v" + pi.versionName;
        versionCode = pi.versionCode;

        List<PackageInfo> apps = getPackageManager().getInstalledPackages(0);
        nApk = Integer.toString(apps.size());
        apklist = "";
        for (PackageInfo app : apps) {
            apklist += app.packageName + "\t(" + app.versionName + ")\n";
        }
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    showDialog(0);
    initPropList();
    //refresh();
    PageTask task = new PageTask();
    task.execute("");
}

From source file:org.smilec.smile.student.CourseList.java

void setWebviewFontSize(WebView view) {
    WebSettings webSettings = view.getSettings();

    //Determine screen size  xlarge 720x960 dp units
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { // 480x640 dp units
        //Toast.makeText(this, "Large screen",Toast.LENGTH_LONG).show();
        webSettings.setTextSize(WebSettings.TextSize.LARGER);
    } /*/*from   ww w  . j a v a  2  s  . c  o m*/
      else if ((getResources().getConfiguration().screenLayout &      
       Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {     // 320x470 dp units mobile phone
       Toast.makeText(this, "Normal sized screen" , Toast.LENGTH_LONG).show();
              
      } 
      else if ((getResources().getConfiguration().screenLayout &      
       Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {     // 320x426 dp units
       Toast.makeText(this, "Small sized screen" , Toast.LENGTH_LONG).show();
      }
      else {
       Toast.makeText(this, "Screen size is neither large, normal or small" , Toast.LENGTH_LONG).show();
      }*/

}