0

アクティビティにシークバーを配置し、テキスト ビューにシークバーを配置すると、テキスト ビューのフォント サイズが変更されますが、文字列が大きすぎるとシークバーが非常に遅くなります。何かを逃したか、この遅さは正常です

public class TextActivity extends Activity {

    public static TextView textview;
    private SharedPreferences prefs;
    private SeekBar seekbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // Remove title bar
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        // Remove notification bar
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        Window window = getWindow();
        // Unlock the device if locked
        window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
        // Turn screen on if off
        window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
        // Keep screen on
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        // Transition between activities
        overridePendingTransition(R.anim.incoming, R.anim.outgoing);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text);
        // Determine The SeekBar and The EditText
        seekbar = (SeekBar) findViewById(R.id.seekBar1);
        textview = (TextView) findViewById(R.id.id_text_txt);
        // Get Extra From Another Activity
                Intent n = getIntent();
                String mrng = n.getStringExtra("key");
                 textview.setText(Html.fromHtml(mrng));
        // Save Preferences
        prefs = getPreferences(MODE_PRIVATE);

        float fs = prefs.getFloat("fontsize", 40);
        seekbar.setProgress((int) fs);
        textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, seekbar.getProgress());

        // Programming SeekBar
        seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                prefs = getPreferences(MODE_PRIVATE);
                SharedPreferences.Editor ed = prefs.edit();
                ed.putFloat("fontsize", textview.getTextSize());
                ed.commit();
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // nothing
            }

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {
                textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, progress);
            }
        });
    }
}

何か助けて??

4

0 に答える 0