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

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

webview動態(tài)設(shè)置瀏覽字體大小

2019-11-11 04:52:11
字體:
供稿:網(wǎng)友

原博客地址: 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>我在在新聞詳情頁設(shè)置改變字體ImageButton的點擊事件后進(jìn)入以下方法:

/**     * 顯示選擇對話框     */    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://就是通過設(shè)置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;                }                 //保存用戶選擇的狀態(tài)                mCurrentItem = mCurrentChooseItem;            }        });        builder.setNegativeButton("取消", null);        builder.show();    }


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 伊吾县| 霞浦县| 阿拉善右旗| 临朐县| 西平县| 通辽市| 鄯善县| 伊通| 永泰县| 股票| 江城| 五大连池市| 聂拉木县| 靖江市| 涿州市| 高雄县| 炉霍县| 马龙县| 西峡县| 静海县| 中山市| 开化县| 九台市| 延川县| 宜兰市| 奉新县| 湘潭县| 伊宁县| 本溪市| 白银市| 岗巴县| 邹城市| 巴林右旗| 嘉兴市| 故城县| 水城县| 隆尧县| 松溪县| 塔河县| 桐庐县| 容城县|