├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── tomergoldst │ │ └── tooltipsdemo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── OFL.txt │ │ └── Pacifico-Regular.ttf │ ├── java │ │ └── com │ │ │ └── tomergoldst │ │ │ └── tooltipsdemo │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── menu │ │ └── main_activity_actions.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── tomergoldst │ └── tooltipsdemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── tooltips ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── tomergoldst │ └── tooltips │ └── ApplicationTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── tomergoldst │ │ └── tooltips │ │ ├── Coordinates.java │ │ ├── DefaultToolTipAnimator.java │ │ ├── ToolTip.java │ │ ├── ToolTipAnimator.java │ │ ├── ToolTipBackgroundConstructor.java │ │ ├── ToolTipCoordinatesFinder.java │ │ ├── ToolTipsManager.java │ │ └── UiUtils.java └── res │ ├── drawable-xxhdpi │ ├── tooltip_arrow_down.9.png │ ├── tooltip_arrow_down_left.9.png │ ├── tooltip_arrow_down_right.9.png │ ├── tooltip_arrow_left.9.png │ ├── tooltip_arrow_right.9.png │ ├── tooltip_arrow_up.9.png │ ├── tooltip_arrow_up_left.9.png │ ├── tooltip_arrow_up_right.9.png │ └── tooltip_no_arrow.9.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml └── test └── java └── com └── tomergoldst └── tooltips └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .idea 7 | .DS_Store 8 | /build 9 | /captures 10 | secring.gpg 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tooltips 2 | Simple to use library for android, Enabling to add a tooltip near any view with ease 3 | 4 | 5 | 6 | ## Instructions 7 | Add a dependency to your app build.gradle 8 | ```groovy 9 | dependencies { 10 | implementation 'com.tomergoldst.android:tooltips:1.1.1' 11 | } 12 | ``` 13 | 14 | Create a `ToolTipsManager` object 15 | ```java 16 | public class MainActivity extends Activity { 17 | 18 | ToolTipsManager mToolTipsManager; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | 25 | mToolTipsManager = new ToolTipsManager(); 26 | 27 | } 28 | 29 | } 30 | ``` 31 | 32 | Use the `ToolTip.Builder` to construct your tip 33 | ```java 34 | public class MainActivity extends Activity { 35 | 36 | @Override 37 | public void onWindowFocusChanged(boolean hasFocus) { 38 | super.onWindowFocusChanged(hasFocus); 39 | 40 | ToolTip.Builder builder = new ToolTip.Builder(this, mTextView, mRootLayout, "Tip message", ToolTip.POSITION_ABOVE); 41 | } 42 | } 43 | ``` 44 | `mTextView` here is the view which near it the tip will be shown and `mRootLayout` is the layout where the tip view will be added to. 45 | **The root layout must be** of `RelativeLayout`, `FrameLayout` or similar. `LinearLayout` won't work but you can always wrap your `LinearLayout` 46 | with another layout. Prefer to pass in a layout which is higher in the xml tree as this will give the 47 | tip view more visible space. 48 | 49 | **OPTIONAL**: Customize your tip with background color, text color, alignment, text gravity, type face and more. 50 | ```java 51 | public class MainActivity extends Activity { 52 | 53 | @Override 54 | public void onWindowFocusChanged(boolean hasFocus) { 55 | super.onWindowFocusChanged(hasFocus); 56 | 57 | ToolTip.Builder builder = new ToolTip.Builder(this, mTextView, mRootLayout, "Tip message", ToolTip.POSITION_ABOVE); 58 | builder.setAlign(ToolTip.ALIGN_LEFT); 59 | builder.setBackgroundColor(getResources().getColor(R.color.colorOrange)); 60 | builder.setGravity(ToolTip.GRAVITY_RIGHT); 61 | builder.setTextAppearance(R.style.TooltipTextAppearance); // from `styles.xml` 62 | builder.setTypeface(mCustomFontTypeface); 63 | } 64 | } 65 | ``` 66 | 67 | Here is an example on how you can define your text appearance in your `styles.xml` 68 | 69 | ```xml 70 | 75 | ``` 76 | 77 | You can also customize the animation used to show and hide the tooltip view by providing `ToolTipAnimator` implementation and setting it in the `ToolTipsManager`. 78 | ```java 79 | public class MainActivity extends Activity { 80 | ToolTipsManager mToolTipsManager; 81 | 82 | @Override 83 | protected void onCreate(Bundle savedInstanceState) { 84 | super.onCreate(savedInstanceState); 85 | setContentView(R.layout.activity_main); 86 | 87 | mToolTipsManager = new ToolTipsManager(); 88 | mToolTipsManager.setToolTipAnimator(MyCustomToolTipAnimator()); 89 | } 90 | 91 | } 92 | ``` 93 | 94 | Use `ToolTipManger` to show the tip 95 | 96 | **IMPORTANT**: This must be called after the layout has been drawn 97 | You can override the `onWindowFocusChanged()` of an Activity and show there, Start a delayed runnable from `onStart()`, react to user action or any other method that works for you 98 | ```java 99 | public class MainActivity extends Activity { 100 | 101 | @Override 102 | public void onWindowFocusChanged(boolean hasFocus) { 103 | super.onWindowFocusChanged(hasFocus); 104 | 105 | ToolTip.Builder builder = new ToolTip.Builder(this, mTextView, mRootLayout, "Tip message", ToolTip.POSITION_ABOVE); 106 | 107 | // Rest of builder configurations removed for brevity 108 | 109 | mToolTipsManager.show(builder.build()); 110 | } 111 | } 112 | ``` 113 | 114 | Each tip is dismissable by clicking on it, if you want to dismiss a tip from code there are a few options, the most simple way is to do the following 115 | ```java 116 | public class MainActivity extends Activity { 117 | 118 | @Override 119 | protected void onCreate(Bundle savedInstanceState) { 120 | 121 | mDismissBtn.setOnClickListener(new View.OnClickListener() { 122 | @Override 123 | public void onClick(View view) { 124 | mToolTipsManager.findAndDismiss(mTextView); 125 | } 126 | }); 127 | } 128 | 129 | } 130 | ``` 131 | Where `mTextView` is the same view we asked to position a tip near it 132 | 133 | If you want to react when tip has been dismissed, Implement `ToolTipsManager.TipListener` interface and use appropriate `ToolTipsManager` constructor 134 | ```java 135 | public class MainActivity extends Activity implements ToolTipsManager.TipListener { 136 | 137 | @Override 138 | protected void onCreate(Bundle savedInstanceState) { 139 | mToolTipsManager = new ToolTipsManager(this); 140 | } 141 | 142 | @Override 143 | public void onTipDismissed(View view, int anchorViewId, boolean byUser) { 144 | Log.d(TAG, "tip near anchor view " + anchorViewId + " dismissed"); 145 | 146 | if (anchorViewId == R.id.text_view) { 147 | // Do something when a tip near view with id "R.id.text_view" has been dismissed 148 | } 149 | } 150 | 151 | } 152 | ``` 153 | 154 | ### License 155 | ``` 156 | Copyright 2016 Tomer Goldstein 157 | 158 | Licensed under the Apache License, Version 2.0 (the "License"); 159 | you may not use this file except in compliance with the License. 160 | You may obtain a copy of the License at 161 | 162 | http://www.apache.org/licenses/LICENSE-2.0 163 | 164 | Unless required by applicable law or agreed to in writing, software 165 | distributed under the License is distributed on an "AS IS" BASIS, 166 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 167 | See the License for the specific language governing permissions and 168 | limitations under the License. 169 | ``` 170 | 171 | 172 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 31 5 | 6 | defaultConfig { 7 | applicationId "com.tomergoldst.tooltipsdemo" 8 | minSdkVersion 14 9 | targetSdkVersion 31 10 | versionCode 2 11 | versionName "1.1" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | testImplementation 'junit:junit:4.13.2' 24 | implementation 'com.google.android.material:material:1.4.0' 25 | implementation project(path: ':tooltips') 26 | } 27 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Tomer\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/tomergoldst/tooltipsdemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.tomergoldst.tooltipsdemo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/assets/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2011 The Pacifico Project Authors (https://github.com/Fonthausen/Pacifico) 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /app/src/main/assets/Pacifico-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomergoldst/tooltips/8e2b65ce51f26fee17a142b8fd5078c5b89946a2/app/src/main/assets/Pacifico-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/java/com/tomergoldst/tooltipsdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Tomer Goldstein 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.tomergoldst.tooltipsdemo; 18 | 19 | import android.app.Activity; 20 | import android.graphics.Color; 21 | import android.graphics.Typeface; 22 | import android.os.Bundle; 23 | import android.text.Html; 24 | import android.text.TextUtils; 25 | import android.util.Log; 26 | import android.view.Gravity; 27 | import android.view.Menu; 28 | import android.view.MenuInflater; 29 | import android.view.MenuItem; 30 | import android.view.View; 31 | import android.widget.Button; 32 | import android.widget.RadioButton; 33 | import android.widget.RelativeLayout; 34 | import android.widget.TextView; 35 | import android.widget.Toast; 36 | 37 | import com.google.android.material.textfield.TextInputEditText; 38 | import com.tomergoldst.tooltips.ToolTip; 39 | import com.tomergoldst.tooltips.ToolTipsManager; 40 | 41 | public class MainActivity extends Activity implements 42 | ToolTipsManager.TipListener, 43 | View.OnClickListener { 44 | 45 | private static final String TAG = MainActivity.class.getSimpleName(); 46 | public static final String TIP_TEXT = "Tool Tip"; 47 | public static final String TIP_TEXT_SMALL = "Small Tool Tip"; 48 | public static final String TIP_TEXT_LARGE = "Large Tool Tip"; 49 | 50 | ToolTipsManager mToolTipsManager; 51 | RelativeLayout mRootLayout; 52 | TextInputEditText mEditText; 53 | TextView mTextView; 54 | 55 | Button mAboveBtn; 56 | Button mBelowBtn; 57 | Button mLeftToBtn; 58 | Button mRightToBtn; 59 | 60 | RadioButton mAlignRight; 61 | RadioButton mAlignLeft; 62 | RadioButton mAlignCenter; 63 | 64 | @ToolTip.Align 65 | int mAlign = ToolTip.ALIGN_CENTER; 66 | 67 | Typeface mCustomFont = null; 68 | 69 | @Override 70 | protected void onCreate(Bundle savedInstanceState) { 71 | super.onCreate(savedInstanceState); 72 | setContentView(R.layout.activity_main); 73 | 74 | mRootLayout = findViewById(R.id.root_layout); 75 | mTextView = findViewById(R.id.text_view); 76 | 77 | mToolTipsManager = new ToolTipsManager(this); 78 | 79 | mAboveBtn = findViewById(R.id.button_above); 80 | mBelowBtn = findViewById(R.id.button_below); 81 | mLeftToBtn = findViewById(R.id.button_left_to); 82 | mRightToBtn = findViewById(R.id.button_right_to); 83 | 84 | mAboveBtn.setOnClickListener(this); 85 | mBelowBtn.setOnClickListener(this); 86 | mLeftToBtn.setOnClickListener(this); 87 | mRightToBtn.setOnClickListener(this); 88 | mTextView.setOnClickListener(this); 89 | 90 | mAlignCenter = findViewById(R.id.button_align_center); 91 | mAlignRight = findViewById(R.id.button_align_right); 92 | mAlignLeft = findViewById(R.id.button_align_left); 93 | 94 | mAlignCenter.setOnClickListener(this); 95 | mAlignLeft.setOnClickListener(this); 96 | mAlignRight.setOnClickListener(this); 97 | 98 | mAlignCenter.setChecked(true); 99 | 100 | mEditText = findViewById(R.id.text_input_edit_text); 101 | 102 | } 103 | 104 | @Override 105 | public boolean onCreateOptionsMenu(Menu menu) { 106 | MenuInflater inflater = getMenuInflater(); 107 | inflater.inflate(R.menu.main_activity_actions, menu); 108 | return true; 109 | } 110 | 111 | @Override 112 | public boolean onOptionsItemSelected(MenuItem item) { 113 | // Handle item selection 114 | switch (item.getItemId()) { 115 | case R.id.use_custom_font_menu_item: 116 | mCustomFont = Typeface.createFromAsset(getAssets(), "Pacifico-Regular.ttf"); 117 | Toast toast = Toast.makeText(this, "Custom font set. Re-try demo.", Toast.LENGTH_SHORT); 118 | toast.setGravity(Gravity.CENTER, 0, 0); 119 | toast.show(); 120 | return true; 121 | default: 122 | return super.onOptionsItemSelected(item); 123 | } 124 | } 125 | 126 | 127 | @Override 128 | public void onWindowFocusChanged(boolean hasFocus) { 129 | super.onWindowFocusChanged(hasFocus); 130 | 131 | // This tip is shows the first time the sample app is loaded. Use a message that gives user 132 | // guide on how to use the sample app. Also try to showcase the ability of the app. 133 | CharSequence initialGuideTex = Html.fromHtml("Click on the Buttons " + 134 | "and the Radio Buttons bellow to test various tool tip configurations." + 135 | "

GOT IT"); 136 | 137 | ToolTip.Builder builder = new ToolTip.Builder(this, mTextView, mRootLayout, initialGuideTex, ToolTip.POSITION_ABOVE); 138 | builder.setAlign(mAlign); 139 | builder.setBackgroundColor(Color.DKGRAY); 140 | builder.setTextAppearance(R.style.TooltipTextAppearance); 141 | mToolTipsManager.show(builder.build()); 142 | } 143 | 144 | @Override 145 | public void onTipDismissed(View view, int anchorViewId, boolean byUser) { 146 | Log.d(TAG, "tip near anchor view " + anchorViewId + " dismissed"); 147 | 148 | if (anchorViewId == R.id.text_view) { 149 | // Do something when a tip near view with id "R.id.text_view" has been dismissed 150 | } 151 | } 152 | 153 | @Override 154 | public void onClick(View view) { 155 | String text = TextUtils.isEmpty(mEditText.getText()) ? TIP_TEXT : mEditText.getText().toString(); 156 | ToolTip.Builder builder; 157 | 158 | switch (view.getId()) { 159 | case R.id.button_above: 160 | mToolTipsManager.findAndDismiss(mTextView); 161 | builder = new ToolTip.Builder(this, mTextView, mRootLayout, text, ToolTip.POSITION_ABOVE); 162 | builder.setAlign(mAlign); 163 | builder.setTypeface(mCustomFont); 164 | mToolTipsManager.show(builder.build()); 165 | break; 166 | case R.id.button_below: 167 | mToolTipsManager.findAndDismiss(mTextView); 168 | builder = new ToolTip.Builder(this, mTextView, mRootLayout, text, ToolTip.POSITION_BELOW); 169 | builder.setAlign(mAlign); 170 | builder.setTextAppearance(R.style.TooltipTextAppearance); 171 | builder.setTypeface(mCustomFont); 172 | builder.setBackgroundColor(getResources().getColor(R.color.colorOrange)); 173 | mToolTipsManager.show(builder.build()); 174 | break; 175 | case R.id.button_left_to: 176 | mToolTipsManager.findAndDismiss(mTextView); 177 | builder = new ToolTip.Builder(this, mTextView, mRootLayout, TIP_TEXT.equals(text) ? TIP_TEXT_SMALL : text, ToolTip.POSITION_LEFT_TO); 178 | builder.setBackgroundColor(getResources().getColor(R.color.colorLightGreen)); 179 | builder.setGravity(ToolTip.GRAVITY_CENTER); 180 | builder.setTypeface(mCustomFont); 181 | builder.setTextAppearance(R.style.TooltipTextAppearance_Small_Black); 182 | mToolTipsManager.show(builder.build()); 183 | break; 184 | case R.id.button_right_to: 185 | mToolTipsManager.findAndDismiss(mTextView); 186 | builder = new ToolTip.Builder(this, mTextView, mRootLayout, TIP_TEXT.equals(text) ? TIP_TEXT_LARGE : text, ToolTip.POSITION_RIGHT_TO); 187 | builder.setBackgroundColor(getResources().getColor(R.color.colorDarkRed)); 188 | builder.setTextAppearance(R.style.TooltipTextAppearance_Large); 189 | builder.setTypeface(mCustomFont); 190 | mToolTipsManager.show(builder.build()); 191 | break; 192 | case R.id.button_align_center: 193 | mAlign = ToolTip.ALIGN_CENTER; 194 | break; 195 | case R.id.button_align_left: 196 | mAlign = ToolTip.ALIGN_LEFT; 197 | break; 198 | case R.id.button_align_right: 199 | mAlign = ToolTip.ALIGN_RIGHT; 200 | break; 201 | case R.id.text_view: 202 | mToolTipsManager.dismissAll(); 203 | break; 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 17 | 18 | 26 | 27 | 28 | 29 | 36 | 37 | 43 | 44 |