Giter Site home page Giter Site logo

interactivetextmaker's Introduction

Interactive Text Maker

Header Image

The goal of this project is to make texts in TextView clickable and also translatable easily.

User separates each special word with separator characters like "__" and then when tapping all the custom words inside the TextView The .setOnTextClickListener(InteractiveTextMaker) or addOnSpecialWordClickListener(InteractiveTextView) function is called with the index of the touched word. In this way, sentences can be translated into other languages more easily and The locations of tactile sentences remain fixed in all languages.

Medium Article: https://medium.com/p/2b70e2072453

Installation

You can copy the InteractiveTextMaker class or add as a dependency to your project.

Step 1. Add the JitPack repository to your build file

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add The InteractiveTextMaker Dependency

dependencies {
    implementation 'com.github.Alonew0lfxx:InteractiveTextMaker:1.0.3'
}

NEW! InteractiveTextView

You can also see the preview of your text with your special words processed.
<com.alonew0lfxx.interactivetextmaker.InteractiveTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:fontFamily="@font/bold"
        app:specialTextUnderlined="true"
        android:text="How To __Make__ Clickable __Text__ In A __TextView__?" />

InteractiveTextView Result

App Screenshot

Example Usage of InteractiveTextMaker

class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        binding.textView.text = "How To __Make__ Clickable __Text__ In A __TextView__?"
        InteractiveTextMaker.of(binding.textView)
            .setSpecialTextColor(R.color.purple_500)
            .setSpecialTextFontFamily(R.font.bold_italic)
            .setSpecialTextUnderLined(true)
            .setOnTextClickListener {
                when (it) {
                    0 -> Toast.makeText(this, "'Make' has been clicked", Toast.LENGTH_SHORT).show()
                    1 -> Toast.makeText(this, "'Text' has been clicked", Toast.LENGTH_SHORT).show()
                    2 -> Toast.makeText(this, "'TextView' has been clicked", Toast.LENGTH_SHORT)
                        .show()
                }
            }
            .initialize()
        setContentView(binding.root)
    }
}

InteractiveTextMaker Result

App Screenshot

License

MIT

interactivetextmaker's People

Contributors

emirhankolver 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.