Android Open Source - android-autofittextview Sample Activity






From Project

Back to project page android-autofittextview.

License

The source code is released under:

Apache License

If you think the Android project android-autofittextview listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.grantland.autofittextview.sample;
//from w  ww  .jav  a 2  s  .c  om
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

public class SampleActivity extends Activity {

    private TextView mOutput, mAutofitOutput;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mOutput = (TextView)findViewById(R.id.output);
        mAutofitOutput = (TextView)findViewById(R.id.output_autofit);

        ((EditText)findViewById(R.id.input)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                // do nothing
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                mOutput.setText(charSequence);
                mAutofitOutput.setText(charSequence);
            }

            @Override
            public void afterTextChanged(Editable editable) {
                // do nothing
            }
        });
    }
}




Java Source Code List

me.grantland.autofittextview.sample.SampleActivity.java
me.grantland.widget.AutofitHelper.java
me.grantland.widget.AutofitLayout.java
me.grantland.widget.AutofitTextView.java