How to make EditText not editable but scrollable

EditText not Editable but Scrollable

When we need to show long text like Terms and conditions in EditText. We need to allow scrolling and it should not be editable.


For this I tried in XML set EditText attributes to show vertical scrollbars


And then to make EditText not editable i tried different ways like


not worked, and also tried


but it is deprecated.

And then tried this line in code


Its not allowed to Edit. But unable scroll text in EditText.

And Finally i found the work around for it. Added this line in code.


It worked perfectly….

Hope this helps somebody….

You may be also interested in


Html tags in Text not working in TextView

Here I try to explain the details why Html tags in Text not working in TextView. At times you may need to display text with Bold and normal style in TextView like this,  …(You may skip to solution )

Html Tags in Text

Welcome, to your favorite music app store.   

So, you’ll define a string in string.xml file as follows

<string name="welcome_text"><b>Welcome,</b> to your favorite music app store.</string>

You’ll apply this wecome_text in a TextView in Java code as below.

TextView tvWelcomeUser=(TextView)findViewById(;

If you apply setText(int resID) as shown above you can see the text in TextView as expected “Welcome, to your favorite music app store.”

But if you like to display dynamically generated text after Welcome message, as shown below

Welcome, to your favorite music app store. Logged in as: <username>

here <username> is dynamically generated text. You can do this in two ways,

One way is concatenate dynamic text using “+” symol

tvWelcomeUser.setText(getString(R.string.welcome_text) + " Logged in as:" + username);

Another way is defining string in strings.xml file

//in string.xml file
<string name="welcome_text"><b>Welcome,</b> to your favorite music app store. Logged in as: %1$s.</string>

You’ll assign to TextView in Java code like this

//and in Java code

Here comes the issue, In both ways you’ll miss bold text for Welcome text.

even if you try this Html.fromSting(string) method it wont work.

//and in Java code

You may wondering about this issue, why its not working suddenly which worked before. The reason for this issue is you are converting to String which ignores html tags.

Html tags in Text not working in TextView Solution:

The only solution for this issue is using CData sections for the string in strings.xml file as shown below

//in string.xml file
<string name="welcome_text"><![CDATA[<b>Welcome,</b> to your favorite music app store. Logged in as:]]> %1$s.</string>

Now in Java code you can assign like this,

//and in Java code
String welcomStr=String.format(getString(R.string.welcome_text),username);

CData section in string text keeps the html tag data intact even after formatting text using String.format method. So, Html.fromHtml(str) works fine and you’ll see the bold text in Welcome message.

Welcome, to your favorite music app store. Logged in as: <username>

It displays bold text as expected. horray… 🙂

Hope it helps somebody… 😎

You may be also interested in


Issues after updating to Android Studio 2.0v

In this post, I just like to sum up all the issues faced after updating Android version.

After updating to Android Studio 2.0v, you may see following issues.

You’ll be asked to install latest gradle version to enable Instant Run. you think it helps and installs the latest Gradle version.

Now, your problems starts You may be able build project. But couldn’t able to run the project. When you run the project, you’ll see Out of memory exception as below. 😐

Error:java.lang.OutOfMemoryError: Java heap space.
Please assign more memory to Gradle in the project's file.
For example, the following line, in the file, sets the maximum Java heap size to 1,024 MB:
<a href="">Read Gradle's configuration guide</a><br><a href="">Read about Java's heap size</a>

I tried different ways to increase the memory, like changing the memory values in file

org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=512m

and changing values in studio64.exe.vmoptions file in C:\Program Files\Android\Android Studio\bin folder


but not worked. 🙁

The only thing that worked for me is adding javaMaxHeapSize value of dexOptions in app’s build.gradle file.

  dexOptions {
     javaMaxHeapSize "2g"

this fixes the OutOfMemoryError issue. The reason for this issue is the latest version gradle needs more memory to build the app.

And after fixing You may see Multiple dex files issue. For me I get this error

Cause: Multiple dex files define Lcom/google/zxing/BarcodeFormat;  😮

I tried following to fix this issue

defaultConfig {
// Enabling multidex support.
multiDexEnabled true

Which resulted same issue in different way 😡

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> duplicate entry: com/google/zxing/BarcodeFormat.class

in inconsistent location 'C:\Users\employee2\AppData\Local\Android\sdk\add-ons\addon-google_apis-google-19-1'
(Expected 'C:\Users\employee2\AppData\Local\Android\sdk\add-ons\addon-google_apis-google-19')

Error:Error converting bytecode to dex:

So, I removed that multiDexEnabled true line and search for the BarcodeFormat class usage in project. I finally find out that same dependencies library added in module’s and app’s  build.gradle file. I just commented dependencies library in app’s build.gradle file fixed the issue.  😎

So, finally After fixing all issues and you’ll be able to run the app. 

And then, now you made some code changes and run the app. App won’t run on device with latest code changes. In the Android Studio Run tab you’ll see “No changes”.  What! 😮

The reason for this Instant Run not recognizes certain code changes, and it also needs latest android API.


So, the only option to see your code changes effect in app and run on device, is disable Instant Run. Please see following image to disable

after updating

That’s it now you able to see code changes by running the app on device.  😎


Hope it saves somebodies time. 💡


You may also interested in


Simple Weekview calendar implemented using GridView

Simple Weekview calendar implemented using GridView.

I tried to search for a simple Weekview calendar, which display 7 week days. But not able to find a simple one. So i implemented simple weekview calendar which just displays 7 week days with left right buttons to load prev/next week days.


Weekview calendar

Simple Weekview calendar implemented using GridView.

Download source code from this link.

Hope it helps somebody.

You may be also interested in..

To download latest version, no Update and Restart button in Android Studio

In Android Studio, you may see “A new version Android Studio available” popup message at the top right corner, whenever latest version available to update.

latest version

When you click on that popup message link, you’ll see a dialog with a button, which allow you Update and Restart Android Studio. But at times you may not see Update and Restart button, as shown below.


As shown in above image, There’s no button to Update version. You may be wonder why and how you can get install the latest version.

Solution to download latest version:

Here is the solution to fix that issue.

Goto Settings-> Appearance & Behavior -> System Setting -> Click on Updates and then in the right panel you’ll Check Now button.


Click on Check Now button. It’ll check for the latest update and fixes download issue. Now close the Setting window. And try again to Click on “A new version Android Studio available” popup message link.

You’ll see Update and Restart button. Click on it You’ll get the latest version installed.



Hope it helps somebody.


You may also interested in


Flash or Pulse Animation for a Button Android

At times we may require to get user’s attention to click on a Button, to view some important information in app. For this purpose Flash or Pulse animation helps us very well. Below are code snippets to implement these animations.

Implementing Flash animation

We can use AnimationDrawable class, to add frames of two different colours, which produces flash animation. Below is an example code.

Here im displaying rounded shape button, so i used RoundRectShape class, given radii as argument. If you want a rectangle shape, just replace radii withnull

AnimationDrawable adBtn;

private void applyFlashBackgroundAnimation(){
     float[] radii = new float[8];
     radii[0] = getResources().getDimension(R.dimen.spacing_10);
     radii[1] = getResources().getDimension(R.dimen.spacing_10);
     radii[2] = getResources().getDimension(R.dimen.spacing_10);
     radii[3] = getResources().getDimension(R.dimen.spacing_10);

     radii[4] = getResources().getDimension(R.dimen.spacing_10);
     radii[5] = getResources().getDimension(R.dimen.spacing_10);
     radii[6] = getResources().getDimension(R.dimen.spacing_10);
     radii[7] = getResources().getDimension(R.dimen.spacing_10);
     ShapeDrawable selShape = new ShapeDrawable();
     selShape.setShape(new RoundRectShape(radii, null, null));

     ShapeDrawable defShape = new ShapeDrawable();
     defShape.setShape(new RoundRectShape(radii, null, null));
     adBtn = new AnimationDrawable();
     adBtn.addFrame(selShape, DELAY);
     adBtn.addFrame(defShape, DELAY);
     btnObj.setBackgroundDrawable(adPick);//btnObj is your Button object
     Handler handler== new Handler();
     handler.postDelayed(new Runnable() {
          public void run() {
     }, 100);

//To Stop Animation, simply use stop method of AnimationDrawable object as below.
private void stopFlashAnimation()

Implementing Pulse animation

To produce Pulse or Heartbeat animation, we use ObjectAnimator class. Below is the example code.

ObjectAnimator objAnim;
private void pulseAnimation(){
    objAnim= ObjectAnimator.ofPropertyValuesHolder(btnObj, PropertyValuesHolder.ofFloat("scaleX", 1.5f), PropertyValuesHolder.ofFloat("scaleY", 1.5f));

//To Stop Animation, simply use cancel method of ObjectAnimator object as below.

private void stopPulseAnimation()

That’s it.

Hope it helps somebody… 🙂

You may also interested in..

Integrate BitBucket Plug-in Android Studio

You can push project to Bit Bucket without using Terminal in Android Studio. To do that you need a Bitbucket plug-in.

Install BitBucket Plug-in

You can download BitBucket plugin from this link. After downloading zip file don’t unzip it. Goto Android Studio, press Ctrl+Alt+S, and search for Plugins in left panel. You will see Plugins tab in right panel.


Click on Install plugin from disk,


Select downloaded BitBucket zip file and Click on Apply,

BitBucket Plug-in

It’ll ask to restart Android Studio. Click Restart button.

After restarting, Your BitBucket Plug in is installed and ready to use. Now to start Push all your project to BitBucket.

Goto- VCS menu-> and select Enable Version Control Integration.


You’ll be prompted to select Version control system for the project root, here select Git as Bit Bucket uses git system


Now Goto, BitBucket website and Create a new repository with same name as project.


You’ll see Command line syntax to init push code. Just copy the bitbucket origin Url as shown below.


Now Goto AndroidStudio, select project and Git->Add as shown below


And then Commit the changes as shown below.


Enter initial Comment for project and then select Commit and Push as shown below.


Here, You’ll ask to define remote,


Click on it and Enter URL that we copied from Bit Bucket command line syntax.


You’ll be able to Push code to the repository. Click on Push button


Now Go to, Bit bucket website you’ll see project files Committed to your repository.


That’s it. You just Pushed all your Project to Bit bucket without using Terminal window.

Hope it helps somebody.


You may also interested in

Beautiful messages collected



  1. Stay away from anger, it hurts only you.
  2. If you are right then there is no need to get angry, and if you are wrong then you don’t have any right to get angry.
  3. Patience with family is love, Patience with others is respect. Patience with self is confidence and Patience with GOD is faith.
  4. Never think hard about the PAST, It brings tears. Don’t think more about the FUTURE, It brings fears. Live this moment with a smile, it brings cheers.
  5. Every test in our life makes us bitter or better, every problem comes to make us or break us, The choice is ours whether we become victims or victorious.
  6. Beautiful things are not always good but good things are always beautiful.
  7. Do you know why God created gaps between fingers? So that someone who is special to you comes and fills those gaps by holding your hand forever.
  8. Happiness keeps you sweet so try n be as happy from within as possible.
  9. God has sent us all in pairs, someone somewhere is made for u. So wait for the right time n right moment.

copied message 🙂

You may be also interested in


Create new Class extends a SuperClass- Android Studio

In Android studio, If you want to create a new Class extends a SuperClass, built-in menu doesn’t provide option for it.

Create a Class extends a SuperClass

Where as you can only Create a new Class and then manually write down extends Superclass.

Image 1
Image 2

To add Create new Class which extends a SuperClass, you need to Create a new Template

Press Ctrl+Alt+S to open Settings  window, here search for File and Code Templates

Image 3

Click + button to add new template, give a name as Inheritance(you can give any name) and write this below code

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != “”)package ${PACKAGE_NAME};#end
public class ${NAME} extends ${SUPERCLASS} {

Apply it and the Click Ok button. as shown below

Image 4

Now go to project and try to create new class as shown Image 1 above..

and  you’ll see newly added template in dropdown as shown below.


Select it and then you’ll be asked to enter Super class name. Enter your Super class name.


That’s it.

You’ll see new Class created with SuperClass.

Hope it helps somebody.

You may also interested in


Gradle DSL method not found – Android Studio

After importing Eclipse project to Android Studio. When you run the project, you may see following error message as, Gradle DSL not found: ‘android()’

Gradle DSL

Solution to fix this Gradle DSL method issue

open Top-level build.gradle file of the project


And remove the following code lines.

android {
compileSdkVersion 21
buildToolsVersion '21.1.2'

And then click Sync menu button, fixes the issue.


And another possible issue is,

Gradle DSL method not found: ‘runProguard()’

At times when you import a downloaded sample project in to Android Studio, see following error message as, Gradle DSL not found: ‘runProguard()’


Solution to fix this Gradle DSL method issue

open app’s build.gradle file of the project


In this file you can see following code snippet

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

In the above code runProguard false causing the issue. Change that line to

minifyEnabled false

Now click Sync menu button, issue will be fixed. I see the reason for this is runProguard has been renamed to minifyEnabled in version 0.14.0 or more in Gradle.

Hope it helps somebody. 😎

You may be also interested in