Saturday, July 22, 2017

Android development - Adding scrollbar in your activity

Adding scroll bar in your activity in your mobile application can be done easily.

e.g. You have main layout for your mobile application as below

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    tools:context="com.learning.course.letslearn.MainMenu"    android:orientation="vertical"    android:layout_weight="100"    android:layout_marginLeft="15dp"    android:layout_marginRight="15dp"    android:layout_marginTop="15dp"    >
.............
.............
.............
</LinearLayout>

Enclosing this with scroll view will ensure that whenever screen have less vertical space an scroll bar will be displayed

xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/ScrollView01"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:fillViewport="true"    android:layout_marginBottom="10dp"    >

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    tools:context="com.learning.course.letslearn.MainMenu"    android:orientation="vertical"    android:layout_weight="100"    android:layout_marginLeft="15dp"    android:layout_marginRight="15dp"    android:layout_marginTop="15dp"    >
.............
.............
.............
</LinearLayout>
</ScrollView>

How To hide windows title bar in your android application

Perform following steps

In your style file (app\src\main\res\values\styles.xml)  add following lines. This will create another theme with NotTitle

<style name="FullscreenTheme" parent="AppTheme">
    <item name="windowNoTitle">true</item>
</style>

Apply newly created style/theme to your activity using application manifest file (app\src\main\AndroidManifest.xml) as shown in highlighted text
.....
<activity android:name=".MainMenu" android:theme="@style/FullscreenTheme"
     >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
......



Android Studio - Taking screen shot using android emulator

You might need to take screenshot our application for various purpose e.g. Presentation etc.

You may follow below steps to capture screenshot of your application in Android Emulator.

Run project and select already configured emulator
From Emulator screen click on screen capture button ("Camera icon") to capture screen as shown below

After taking snapshot you may access this using Android monitor. Click on camera icon as shown below

Once you click camera icon it will open screen shot as shown below and you can click save button to copy snapshot to your disk


Java IDE for Grail Development

Choosing the right IDE in java development is important as it will directly impact your development.

following are few famous IDEs available for java

1. Intelli J
2. Eclipse

For me Intelli J only worked if you have ultimate edition. Though I like IntelliJ but Eclipse looks better option for me.

Assuming that JDK is already installed (Please see earlier post related to JDK install for more details)
Assuming that grails is already installed (Please see earlier post related to grails install for more details)

In order to run it with eclipse first download STS
http://spring.io/tools/sts

STS installation is a copy paste install

unzip the file and it wil have everything. run sts.exe

   cd %grails_home%
   cd
 
grails integrate-with --eclipse
grails compile
grails download-sources-and-javadocs
grails sts-link-sources-and-javadocs