如何使用贴纸视图更改settext大小

时间:2017-02-16 05:31:10

标签: android dialog

我在我的应用程序上工作,我从自定义setText,texcolor和字体    对话框并使用贴纸视图设置活动现在,我的问题是    当我将文字调用到活动@sticker textview时,却可以zoomin    或者出去。

以下是我的代码:

 textsys.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // custom dialog
            final Dialog dialog = new Dialog(context);
            dialog.setContentView(R.layout.popup_text);

            // set the custom dialog components - text, image and button
            final EditText poupedittext = (EditText) dialog.findViewById(R.id.poupedittext);
            final TextView popupcolor = (TextView) dialog.findViewById(R.id.popupcolor);
            final Spinner spin = (Spinner) dialog.findViewById(R.id.spin);
            TextView popupdelete = (TextView) dialog.findViewById(R.id.popupdelete);
            TextView popupdone = (TextView) dialog.findViewById(R.id.popupdone);
            //final_result = poupedittext.getText().toString();
            popupcolor.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ColorPickerDialogBuilder
                            .with(Frame_Selected.this)
                            .setTitle("Choose color")
                            .initialColor(currentBackgroundColor)
                            .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
                            .density(12)
                            .setOnColorSelectedListener(new OnColorSelectedListener() {
                                @Override
                                public void onColorSelected(int selectedColor) {
                                    selectcolor = selectedColor;
                                    Toast.makeText(getApplicationContext(), "onColorSelected: 0x" + selectedColor, Toast.LENGTH_SHORT).show();
                                }
                            })
                            .setPositiveButton("ok", new ColorPickerClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
                                    changeBackgroundColor(selectedColor);
                                }

                                private void changeBackgroundColor(int selectedColor) {
                                    currentBackgroundColor = selectedColor;
                                    poupedittext.setTextColor(selectedColor);
                                }
                            })
                            .setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            })
                            .build()
                            .show();
                    popupcolor.setTextColor(popupcolor.getTextColors());
                }

            });
            // Spinner element
            // Spinner Drop down elements
            List<String> categories = new ArrayList<String>();
            categories.add("Above");
            categories.add("Airways");
            categories.add("Alger");
            categories.add("Digifaw");
            categories.add("Itckrist");
            categories.add("Jokerman");
            categories.add("Ojason");
            categories.add("Oldengl");// Creating adapter for spinner
            categories.add("Rosewood");// Creating adapter for spinner
            ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(Frame_Selected.this, android.R.layout.simple_spinner_item, categories);
            // Drop down layout style - list view with radio button
            dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            // attaching data adapter to spinner
            spin.setAdapter(dataAdapter);
            spin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                    font = Selected_font;

                    switch (position) {
                        case 0:
                            String a = "fonts/Above.ttf";
                            Typeface face = Typeface.createFromAsset(getAssets(), a);
                            poupedittext.setTypeface(face);
                            Selected_font = a;
                            break;
                        case 1:
                            String b = "fonts/Airways.ttf";
                            Typeface face1 = Typeface.createFromAsset(getAssets(), b);
                            poupedittext.setTypeface(face1);
                            Selected_font = b;
                            break;
                        case 2:
                            String c = "fonts/ALGER.ttf";
                            Typeface face2 = Typeface.createFromAsset(getAssets(), c);
                            poupedittext.setTypeface(face2);
                            Selected_font = c;
                            break;
                        case 3:
                            String d = "fonts/digifaw.ttf";
                            Typeface face3 = Typeface.createFromAsset(getAssets(), d);
                            poupedittext.setTypeface(face3);
                            Selected_font = d;
                            break;
                        case 4:
                            String e = "fonts/ITCKRIST.TTF";
                            Typeface face4 = Typeface.createFromAsset(getAssets(), e);
                            poupedittext.setTypeface(face4);
                            Selected_font = e;
                            break;
                        case 5:
                            String f = "fonts/JOKERMAN.TTF";
                            Typeface face5 = Typeface.createFromAsset(getAssets(), f);
                            poupedittext.setTypeface(face5);
                            Selected_font = f;
                            break;
                        case 6:
                            String g = "fonts/JUICE_Regular.ttf";
                            Typeface face6 = Typeface.createFromAsset(getAssets(), g);
                            poupedittext.setTypeface(face6);
                            Selected_font = g;
                            break;
                        case 7:
                            String h = "fonts/oj.TTF";
                            Typeface face7 = Typeface.createFromAsset(getAssets(), h);
                            poupedittext.setTypeface(face7);
                            Selected_font = h;
                            break;
                        case 8:
                            String j = "fonts/OLDENGL.TTF";
                            Typeface face8 = Typeface.createFromAsset(getAssets(), j);
                            poupedittext.setTypeface(face8);
                            Selected_font = j;
                            break;
                        case 9:
                            String k = "fonts/Rosewood.TTF";
                            Typeface face9 = Typeface.createFromAsset(getAssets(), k);
                            poupedittext.setTypeface(face9);
                            Selected_font = k;
                            break;

                        default:
                            String def = "fonts/Above.ttf";
                            Typeface faced = Typeface.createFromAsset(getAssets(), def);
                            poupedittext.setTypeface(faced);
                            Selected_font = def;
                            break;
                    }
                    spin.setSelection(position);
                }
                @Override
                public void onNothingSelected(AdapterView<?> parent) {
                }
            });
            popupdone.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    StickerTextView tv_sticker = new StickerTextView(Frame_Selected.this);
                stickertext=poupedittext.getText().toString();
                    //set text
                    tv_sticker.setText(stickertext);
                    //set color
                    tv_sticker.setColor(selectcolor);
                    //set typeface
                    tv_sticker.setTypeFace(Typeface.createFromAsset(getAssets(),Selected_font));
                    canvas.addView(tv_sticker);
                    dialog.dismiss();
                }
            });
            popupdelete.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            dialog.show();

0 个答案:

没有答案