国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

webview動態設置瀏覽字體大小

2019-11-11 05:29:05
字體:
來源:轉載
供稿:網友

原博客地址: http://blog.csdn.net/codeemperor/article/details/49701543

新聞詳情的布局如下:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <RelativeLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="@drawable/title_red_bg" >        <ImageButton            android:id="@+id/btn_back"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_centerVertical="true"            android:layout_marginLeft="5dp"            android:background="@null"            android:src="@drawable/back" />        <ImageButton            android:id="@+id/btn_share"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignParentRight="true"            android:layout_centerVertical="true"            android:layout_marginRight="5dp"            android:background="@null"            android:src="@drawable/icon_share" />        <ImageButton            android:id="@+id/btn_size"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_centerVertical="true"            android:layout_marginRight="5dp"            android:layout_toLeftOf="@id/btn_share"            android:background="@null"            android:src="@drawable/icon_textsize" />    </RelativeLayout>    <FrameLayout        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1" >        <WebView            android:id="@+id/wv_web"            android:layout_width="match_parent"            android:layout_height="match_parent" />        <PRogressBar            android:id="@+id/pb_progress"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_gravity="center"            android:indeterminateDrawable="@drawable/custom_progress" />    </FrameLayout></LinearLayout>我在在新聞詳情頁設置改變字體ImageButton的點擊事件后進入以下方法:

/**     * 顯示選擇對話框     */    private void showChooseDialog() {        AlertDialog.Builder builder = new AlertDialog.Builder(this);        String[] items = new String[] { "超大號字體", "大號字體", "正常字體", "小號字體", "超小號字體" };        builder.setTitle("字體判斷");        builder.setSingleChoiceItems(items, mCurrentItem, new OnClickListener() {            @Override            public void onClick(DialogInterface dialog, int which) {                mCurrentChooseItem = which;            }        });        builder.setPositiveButton("確定", new OnClickListener() {            WebSettings settings = mWebView.getSettings();            @Override            public void onClick(DialogInterface dialog, int which) {                switch (mCurrentChooseItem) {                case 0://就是通過設置settings的setTextSize來改變字體的大小                                settings.setTextSize(TextSize.LARGEST);                    break;                case 1:                    settings.setTextSize(TextSize.LARGER);                    break;                case 2:                    settings.setTextSize(TextSize.NORMAL);                    break;                case 3:                    settings.setTextSize(TextSize.SMALLER);                    break;                case 4:                    settings.setTextSize(TextSize.SMALLEST);                    break;                default:                    break;                }                 //保存用戶選擇的狀態                mCurrentItem = mCurrentChooseItem;            }        });        builder.setNegativeButton("取消", null);        builder.show();    }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙门县| 上高县| 都兰县| 信阳市| 新干县| 扎赉特旗| 大埔县| 盐山县| 宣恩县| 乌拉特前旗| 鄱阳县| 哈密市| 乡宁县| 瓦房店市| 德化县| 鹰潭市| 二手房| 山阴县| 吉木乃县| 阿勒泰市| 通江县| 景泰县| 临夏市| 正蓝旗| 普宁市| 唐山市| 蒙阴县| 扶风县| 文成县| 佛山市| 乌兰县| 弥勒县| 宁河县| 喀喇沁旗| 金秀| 武山县| 嘉义县| 扎赉特旗| 呈贡县| 上杭县| 乌鲁木齐县|