Git Product home page Git Product logo

resizeableedittextdemo's Introduction

ResizeableEditTextDemo

Resizeable Edit Text like Instagram and WhatsApp Story....

First add below code in activity_main

<FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_centerInParent="true"
    android:background="@color/colorPrimary" >

    <example.com.totalityassesment.AutoFitEditText
        android:id="@+id/rET"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:background="@color/colorPrimary"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:gravity="center_vertical|center_horizontal"
        android:hint="TAP"
        android:isScrollContainer="false"
        android:inputType="textMultiLine|textNoSuggestions"
        android:maxLength="240"
        android:textColor="@android:color/white"
        android:textColorHint="@android:color/white"
        android:textSize="90sp"
        android:textCursorDrawable="@null"/>
</FrameLayout>

And below code in MainActivity.java

public class MainActivity extends AppCompatActivity {

private AutoFitEditText mAutoFitEditText;
private FrameLayout mRootView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRootView=(FrameLayout)findViewById(R.id.container);
    mAutoFitEditText=(AutoFitEditText) findViewById(R.id.rET);

    mAutoFitEditText.setEnabled(true);
    mAutoFitEditText.setFocusableInTouchMode(true);
    mAutoFitEditText.setFocusable(true);
    mAutoFitEditText.setEnableSizeCache(false);
    mAutoFitEditText.setMovementMethod(null);

    mAutoFitEditText.setMaxHeight(100);
    mAutoFitEditText.setMinTextSize(100f);
   // mAutoFitEditText.setLines(1);
    mAutoFitEditText.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction()==KeyEvent.KEYCODE_BREAK ){

                Toast.makeText(MainActivity.this, "PRESSED", Toast.LENGTH_SHORT).show();
                return true;
            }
            return false;
        }
    });

}

}

Create custom class AutoFitEditText.java for resizing the text

resizeableedittextdemo's People

Contributors

shubhamrb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.