Top Menu

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Friday 30 October 2015

Gradle Sync problem - failed to sync Gradle project

Hello guys!!

You may face this sync Gradle project when upgrade the Android Studio or low heap size like this





So here is the solution for it.

For Android Studio 1.3 : (Method 1)
Step 1 : Open gradle.properties file in your Android Studio project.
Step 2 : Add this line at the end of the file
org.gradle.jvmargs=-XX:MaxHeapSize\=256m -Xmx256m Above methods seems to work but if in case it won't then do this (Method 2)
Step 1 : Start Android studio and close any open project (File > Close Project).
Step 2 : On Welcome window, Go to Configure > Settings.
Step 3 : Go to Build, Execution, Deployment > Compiler
Step 4 : Change Build process heap size (Mbytes) to 1024 and Additional build process to VM Options to -Xmx512m.
Step 5 : Close or Restart Android Studio.
Read more...

Monday 26 October 2015

Display HTML format text in WebView

I have faced this problem to show the HTML format text show in WebView
I found the solution for this and lets share it -

Create a xml with WebView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</LinearLayout>

Now create the Activity
package com.example.androidhtmltextsample;

import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebView;

public class MainActivity extends Activity {

 WebView webView;
 
 String mimeType = "text/html";
 String encoding = "utf-8";
 String htmlText = "<ul>\n<li>Apple cider vinegar dries acne without causing any apparent discomfort.</li>" +
        "\n<li>Another interesting acne overnight treatment is the application of toothpaste.</li>" +
        "\n<li>Follow this up by applying a bit of alcohol over the affected area just prior to bedtime.</li>" +
        "\n<li>Do not apply gel based toothpastes on the affected areas.</li>\n</ul>";
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  
  webView = (WebView)findViewById(R.id.webview);
  webView.loadData(htmlText, mimeType, encoding);
 }

}




Now add the Internet Permission in Menifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"    
package="com.example.androidhtmltextsample"    
android:versionCode="1"    
android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8"        
              android:targetSdkVersion="23" />

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application android:allowBackup="true"        
                 android:icon="@drawable/ic_launcher"        
                 android:label="@string/app_name"       
                 android:theme="@style/AppTheme" >
        <activity android:name="com.example.androidhtmltextsample.MainActivity"         
                  android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        
    </application>

</manifest>

Read more...

Thursday 15 October 2015

Can we use strikethrough on sticky notes

The "Sticky Notes" that come with Windows7 happens to be a very good application. With this you can keep a track of your task list by scribbling stuff on it.

Well, since the font formating capabilities of these notes was not very impressive I was just wondering if there is an alternative to strikethrough/strikeout a scribbled line from the note... and guess what! It does have a shortcut... Just like Ctrl+b is for Bold and Ctrl+i is for itallic, Ctrl+t is for Strikethrough/Strikeout.
Read more...

Thursday 8 October 2015

Android Button: Place Image and text in center

Hello Guys!!

If you are facing issue to place image and text at center of any button then please refer my blog -


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">



<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <TableRow
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:weightSum="4">
                    <RelativeLayout
                        android:id="@+id/layout_Views"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_margin="2dp"
                        android:layout_weight="1"
                        android:background="@color/blue">
                        <TextView
                            android:id="@+id/txt_viewCount"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_centerInParent="true"
                            android:gravity="center"
                            android:padding="9dp"
                            android:text="214 Views"
                            android:textColor="#fff" />
                    </RelativeLayout>
                    <RelativeLayout
                        android:id="@+id/layout_Votes"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_margin="2dp"
                        android:layout_weight="1"
                        android:background="@color/red">
                        <TextView
                            android:id="@+id/txt_Votes"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_centerInParent="true"
                            android:gravity="center"
                            android:padding="9dp"
                            android:text="214 Views"
                            android:textColor="#fff" />
                    </RelativeLayout>
                    <RelativeLayout
                        android:id="@+id/layout_share"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_margin="2dp"
                        android:layout_weight="1"
                        android:background="@color/green">
                        <ImageView
                            android:id="@+id/img_share"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerInParent="true"
                            android:src="@drawable/ic_share" />
                    </RelativeLayout>
                    <RelativeLayout
                        android:id="@+id/layout_bookmark"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_margin="2dp"
                        android:layout_weight="1"
                        android:background="@color/yellow">
                        <ImageView
                            android:id="@+id/img_boomark"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerInParent="true"
                            android:src="@drawable/ic_bookmark" />
                    </RelativeLayout>
                </TableRow>
            </TableLayout>
        </LinearLayout>

</LinearLayout>


Output is -

Read more...