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

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

webview動態設置瀏覽字體大小

2019-11-11 04:55:10
字體:
來源:轉載
供稿:網友

原博客地址: 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();    }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 梓潼县| 南乐县| 吐鲁番市| 邓州市| 东明县| 海阳市| 太谷县| 泰来县| 泗洪县| 肃宁县| 阿鲁科尔沁旗| 凉城县| 文安县| 同仁县| 黔西县| 老河口市| 澄迈县| 井陉县| 逊克县| 高雄县| 友谊县| 遵义县| 太仓市| 松原市| 太谷县| 吉安市| 名山县| 霍邱县| 昂仁县| 望城县| 崇信县| 通化县| 柯坪县| 东方市| 古浪县| 墨江| 太和县| 枝江市| 瑞安市| 福安市| 行唐县|