项目作者: twoiq

项目描述 :
Custom EditText and TextView with hashtag highlight
高级语言: Kotlin
项目地址: git://github.com/twoiq/Hashtagify-android.git
创建时间: 2020-03-17T06:15:39Z
项目社区:https://github.com/twoiq/Hashtagify-android

开源协议:Apache License 2.0

下载


Hashtagify-Android


Built with ❤︎ by
Twoiq


Highlight hashtags in EditText and TextInputEditText as text change.

💻 Installation

Add this in your app’s build.gradle file:

  1. dependencies {
  2. implementation 'com.twoiq.hashtagify:hashtagify:1.0.0'
  3. }

Or add hashtagify as a new dependency inside your pom.xml

  1. <dependency>
  2. <groupId>com.twoiq.hashtagify</groupId>
  3. <artifactId>hashtagify</artifactId>
  4. <version>1.0.0</version>
  5. <type>pom</type>
  6. </dependency>

❔ Usage

Use CustomEditText instead of normal EditText to highlight hash tags,

You can use all standard attributes of EditText in CustomEditText

  1. <com.twoiq.hashtagify.CustomEditText
  2. android:id="@+id/customEdt"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. android:layout_margin="16dp"
  6. android:hint="Enter text with #hashtag"
  7. android:textSize="18sp"
  8. android:inputType="textMultiLine"
  9. android:lines="5"
  10. android:textColor="@color/colorPrimary"
  11. app:tagColor="@color/colorAccent"></com.twoiq.hashtagify.CustomEditText>
Use CustomTextInputEditText instead of normal TextInputEditText to highlight hash tags,

You can use all standard attributes of TextInputEditText in CustomTextInputEditText, You can also use it with material TextInputLayout

  1. <com.twoiq.hashtagify.CustomTextInputEditText
  2. android:id="@+id/customTiet"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. android:hint="Enter text with #hashtag"
  6. android:textSize="18sp"
  7. android:inputType="textMultiLine"
  8. android:lines="5"
  9. android:textColor="@color/colorPrimary"
  10. app:tagColor="@color/colorAccent"></com.twoiq.hashtagify.CustomTextInputEditText>
Use TextView instead of normal TextView to highlight hash tags,

You can use all standard attributes of TextView in CustomTextView

  1. <com.twoiq.hashtagify.CustomTextView
  2. android:id="@+id/tvText"
  3. android:layout_width="wrap_content"
  4. android:layout_height="wrap_content"
  5. android:layout_margin="16dp"
  6. android:textSize="18sp"
  7. android:text="Crazy brown #Fox jumps over #Lazy dog"
  8. android:textColor="@color/colorPrimary"
  9. app:tagColor="@color/colorAccent"></com.twoiq.hashtagify.CustomTextView>

🎨 Customization and Attributes

You can use all standard attributes of EditText, TextInputLayout, TextView












Attribute Name Default Value Example Value Description
app:tagColor #1e90ff @color/colorAccent Color of highlighted hashtag for EditText, TextInputLayout, TextView

Change hash tag color (Kotlin)

  1. // EditText
  2. edt.setTagColor(ContextCompat.getColor(this, R.color.colorRed))
  3. // TextInputEditText
  4. tiet.setTagColor(ContextCompat.getColor(this, R.color.colorRed))
  5. // TextView
  6. tv.setTagColor(ContextCompat.getColor(this, R.color.colorRed))

👨 Developed By

  1. Mufaddal Makda

👍 How to Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am ‘Add some feature’)
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

📃 License

  1. Copyright 2020 twoiq
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.