K
K
Kirill Veresnikov2016-11-08 08:12:43
Java
Kirill Veresnikov, 2016-11-08 08:12:43

How to change text size in WebView?

@RequiresApi(api = Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_detail);
        WebView webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setTextZoom(100);

        webView.setBackgroundColor(0x00000000);

        Intent intent = getIntent();
        //получаем строку и формируем имя ресурса
        String resName = "n" + intent.getIntExtra("head", 0);
        Log.i("name", resName);
        Context context = getBaseContext(); //получаем контекст

        //читаем текстовый файл из ресурсов по имени
        String text = readRawTextFile(context, getResources().getIdentifier(resName, "raw", "com.veresnikov.linuxcommands"));

        webView.loadDataWithBaseURL(null, text, "text/html", "en_US", "utf-8" );
    }

If I set the value myself, then everything works fine, but as soon as I start to refer to: The text on the screen is not displayed at all
<integer name="text_stok">100</integer>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Perelygin, 2016-11-08
@orcDamnar

how do you refer? In general, you can not work with zoom:
webview.getSettings().setDefaultFontSize(newFontSize);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question