[GUIDE][HOW TO]Create Android Menus - Android General

Informations
In an Android Application, the menu is one of the most important user interface entities which provides some action options for a particular view.
In this Guide I'm discussing about Creating Android Menus.
Below is a screenshot of the final output:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Guide
In this Guide we are creating a simple menu with 6 menu items.
When clicking on single menu item a simple Toast message will be shown.
Create a new project File ⇒ New ⇒ Android Project and give activity name as AndroidMenusActivity.
Now create an XML file under res/layout folder and name it as menu.xml.
Open menu.xml file and type following code.
In the following code we are creating a single menu with 6 menu items.
Each menu item has an icon and title for display the label under menu icon. Also we have id for each menu item to identify uniquely.
Code:
[FONT="Courier New"][COLOR=#819f07]» menu.xml[/COLOR]
<?[B][COLOR="Teal"]xml[/COLOR][/B] [COLOR="gray"]version[/COLOR]=[COLOR="Blue"]"1.0"[/COLOR] [COLOR="gray"]encoding[/COLOR]=[COLOR="blue"]"utf-8"[/COLOR] ?>
<[B][COLOR="Teal"]menu[/COLOR][/B] [COLOR="Gray"]xmlns:android[/COLOR]=[COLOR="blue"]"http://schemas.android.com/apk/res/android"[/COLOR]>
[COLOR="DarkGreen"]<!-- Single menu item
Set id, icon and Title for each menu item
-->[/COLOR]
<[B][COLOR="Teal"]item[/COLOR][/B] [COLOR="gray"]android:id[/COLOR]=[COLOR="blue"]"@+id/menu_bookmark"[/COLOR]
[COLOR="gray"]android:icon[/COLOR]=[COLOR="blue"]"@drawable/icon_bookmark"[/COLOR]
[COLOR="gray"]android:title[/COLOR]=[COLOR="blue"]"Bookmark"[/COLOR] />
<[B][COLOR="Teal"]item[/COLOR][/B] [COLOR="gray"]android:id[/COLOR]=[COLOR="blue"]"@+id/menu_save"[/COLOR]
[COLOR="gray"]android:icon[/COLOR]=[COLOR="blue"]"@drawable/icon_save"[/COLOR]
[COLOR="gray"]android:title[/COLOR]=[COLOR="blue"]"Save"[/COLOR] />
<[B][COLOR="Teal"]item[/COLOR][/B] [COLOR="gray"]android:id[/COLOR]=[COLOR="blue"]"@+id/menu_search"[/COLOR]
[COLOR="gray"]android:icon[/COLOR]=[COLOR="blue"]"@drawable/icon_search"[/COLOR]
[COLOR="gray"]android:title[/COLOR]=[COLOR="blue"]"Search"[/COLOR] />
<[B][COLOR="Teal"]item[/COLOR][/B] [COLOR="gray"]android:id[/COLOR]=[COLOR="Blue"]"@+id/menu_share"[/COLOR]
[COLOR="gray"]android:icon[/COLOR]=[COLOR="blue"]"@drawable/icon_share"[/COLOR]
[COLOR="gray"]android:title[/COLOR]=[COLOR="blue"]"Share"[/COLOR] />
<[B][COLOR="Teal"]item[/COLOR][/B] [COLOR="gray"]android:id[/COLOR]=[COLOR="blue"]"@+id/menu_delete"[/COLOR]
[COLOR="gray"]android:icon[/COLOR]=[COLOR="blue"]"@drawable/icon_delete"[/COLOR]
[COLOR="gray"]android:title[/COLOR]=[COLOR="blue"]"Delete"[/COLOR] />
<[B][COLOR="Teal"]item[/COLOR][/B] [COLOR="gray"]android:id[/COLOR]=[COLOR="blue"]"@+id/menu_preferences"[/COLOR]
[COLOR="gray"]android:icon[/COLOR]=[COLOR="blue"]"@drawable/icon_preferences"[/COLOR]
[COLOR="gray"]android:title[/COLOR]=[COLOR="blue"]"Preferences"[/COLOR] />
</[B][COLOR="Teal"]menu[/COLOR][/B]>[/FONT]
Now open your main Activity class file (AndroidMenusActivity.java) and type following code.
In the following code each menu item is identified by its ID in switch case statement.
Code:
[FONT="Courier New"][COLOR=#819f07]» AndroidMenusActivity.java[/COLOR]
[B][COLOR="Teal"]package[/COLOR][/B] com.androidhive.androidmenus;
[B][COLOR="Teal"]import[/COLOR][/B] android.app.Activity;
[B][COLOR="Teal"]import[/COLOR][/B] android.os.Bundle;
[B][COLOR="Teal"]import[/COLOR][/B] android.view.Menu;
[B][COLOR="teal"]import[/COLOR][/B] android.view.MenuInflater;
[B][COLOR="teal"]import[/COLOR][/B] android.view.MenuItem;
[B][COLOR="teal"]import[/COLOR][/B] android.widget.Toast;
[B][COLOR="teal"]public class[/COLOR][/B] AndroidMenusActivity [B][COLOR="teal"]extends[/COLOR][/B] Activity {
[COLOR="Gray"]@Override[/COLOR]
[B][COLOR="teal"]public void[/COLOR][/B] onCreate(Bundle savedInstanceState) {
[B][COLOR="teal"]super[/COLOR][/B].onCreate(savedInstanceState);
setContentView(R.layout.main);
}
[COLOR="DarkGreen"]// Initiating Menu XML file (menu.xml)[/COLOR]
[COLOR="gray"]@Override[/COLOR]
[B][COLOR="teal"]public boolean[/COLOR][/B] onCreateOptionsMenu(Menu menu)
{
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.layout.menu, menu);
[B][COLOR="teal"]return true[/COLOR][/B];
}
[COLOR="DarkGreen"] /**
* Event Handling for Individual menu item selected
* Identify single menu item by it's id
* */[/COLOR]
[COLOR="Gray"]@Override[/COLOR]
[B][COLOR="teal"]public boolean[/COLOR][/B] onOptionsItemSelected(MenuItem item)
{
[B][COLOR="teal"]switch[/COLOR][/B] (item.getItemId())
{
[B][COLOR="teal"]case[/COLOR][/B] R.id.menu_bookmark:
[COLOR="DarkGreen"]// Single menu item is selected do something
// Ex: launching new activity/screen or show alert message[/COLOR]
Toast.makeText(AndroidMenusActivity.[B][COLOR="Teal"]this[/COLOR][/B], [COLOR="blue"]"Bookmark is Selected"[/COLOR], Toast.LENGTH_SHORT).show();
[B][COLOR="teal"]return true[/COLOR][/B];
[B][COLOR="teal"]case[/COLOR][/B] R.id.menu_save:
Toast.makeText(AndroidMenusActivity.[B][COLOR="Teal"]this[/COLOR][/B], [COLOR="blue"]"Save is Selected"[/COLOR], Toast.LENGTH_SHORT).show();
[B][COLOR="teal"]return true[/COLOR][/B];
[B][COLOR="teal"]case[/COLOR][/B] R.id.menu_search:
Toast.makeText(AndroidMenusActivity.[B][COLOR="Teal"]this[/COLOR][/B], [COLOR="blue"]"Search is Selected"[/COLOR], Toast.LENGTH_SHORT).show();
[B][COLOR="teal"]return true[/COLOR][/B];
[B][COLOR="teal"]case[/COLOR][/B] R.id.menu_share:
Toast.makeText(AndroidMenusActivity.[B][COLOR="Teal"]this[/COLOR][/B], [COLOR="blue"]"Share is Selected"[/COLOR], Toast.LENGTH_SHORT).show();
[B][COLOR="teal"]return true[/COLOR][/B];
[B][COLOR="teal"]case[/COLOR][/B] R.id.menu_delete:
Toast.makeText(AndroidMenusActivity.[B][COLOR="Teal"]this[/COLOR][/B], [COLOR="blue"]"Delete is Selected"[/COLOR], Toast.LENGTH_SHORT).show();
[B][COLOR="teal"]return true[/COLOR][/B];
[B][COLOR="teal"]case[/COLOR][/B] R.id.menu_preferences:
Toast.makeText(AndroidMenusActivity.[B][COLOR="Teal"]this[/COLOR][/B], [COLOR="Blue"]"Preferences is Selected"[/COLOR], Toast.LENGTH_SHORT).show();
[B][COLOR="teal"]return true[/COLOR][/B];
[B][COLOR="teal"]default[/COLOR][/B]:
[B][COLOR="teal"]return super[/COLOR][/B].onOptionsItemSelected(item);
}
}
}[/FONT]
Finally run your project by Right Clicking on your Project Folder ⇒ Run As ⇒ 1 Android Application to test your application.
Credits
Me - For the topic design.
And I must thank 4 other guys that helped me understand the Android and they're still teaching me:
ihavenick - The first one who helped me understand the Android!
Volk204 - He's the guy that helps me with codes and makes me understand what they do.
Tigrouzen - Lmao! Your kernels are great dude!
Rebellos - He motivated me and I thank him very much!

we are already knew:good: that Romanians are thief ,but just please don't copy paste here !! we have access to the google

Related

Native wifi Hotspot for Verizon S5 Dev Phone

I know this is common knowledge to most, but I thought I would post it here for the Verizon S5 users!!
This guide requires following things:
• APKtool
• Notepad++ (or AcroEdit, etc.)
To Enable Native Hotspot
1. Decompile Framework
2. Edit values/Arrays.xml
Find:
PHP:
<string-array name="config_mobile_hotspot_provision_app">
<item>com.samsung.spg</item>
<item>com.samsung.spg.NewSPGActivity</item>
</string-array>
And Change to:
PHP:
<array name="config_mobile_hotspot_provision_app" />
Should look like this when done:
PHP:
</string-array>
<array name="config_tether_dhcp_range" />
<array name="config_mobile_hotspot_provision_app" />
<integer-array name="config_tether_upstream_types">
<item>0</item>
<item>1</item>
<item>4</item>
<item>5</item>
<item>7</item>
Compile and you can now enjoy Native Hotspot with no Verizon Subscripton
This is not my code I am merely sharing with Verizon S5 users
Enjoy!
This is good but if you install xposed installer you can get the X tether mod and it enables the stock tethering without moving a muscle
razzrmaxx said:
This is good but if you install xposed installer you can get the X tether mod and it enables the stock tethering without moving a muscle
Click to expand...
Click to collapse
That's what I did and it was super simple.
Is this method possible with lollipop android 5.0
EMSpilot said:
I know this is common knowledge to most, but I thought I would post it here for the Verizon S5 users!!
This guide requires following things:
• APKtool
• Notepad++ (or AcroEdit, etc.)
To Enable Native Hotspot
1. Decompile Framework
2. Edit values/Arrays.xml
Find:
PHP:
<string-array name="config_mobile_hotspot_provision_app"> <item>com.samsung.spg</item> <item>com.samsung.spg.NewSPGActivity</item></string-array>
And Change to:
PHP:
<array name="config_mobile_hotspot_provision_app" />
Should look like this when done:
PHP:
</string-array> <array name="config_tether_dhcp_range" /> <array name="config_mobile_hotspot_provision_app" /> <integer-array name="config_tether_upstream_types"> <item>0</item> <item>1</item> <item>4</item> <item>5</item> <item>7</item>
Compile and you can now enjoy Native Hotspot with no Verizon Subscripton
This is not my code I am merely sharing with Verizon S5 users
Enjoy!
Click to expand...
Click to collapse
@EMSpilot
Do you know where this is called from?
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I'm making a debranded rom and this is the only Verizon verbiage left. Thanks in advance for any guidance.
Sent from my LGLS751 using Tapatalk
I have the Verizon s5 but my service is through MetroPCS will this still work for me
How does this work?
I know I am a bit late to this. How does this actually work without a paid carrier? Does this trick the device into receiving data?

3Minit Battery Mod

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
This mod allows you view over 1070 battery type and counting from various users. With a single click the battery will download and set itself on to your status bar.
But as stated don't worry about you storage space being used by thousands of useless icons as they are all on my server and only downloads the type you use.
1.Install app.
2.Decompile SystemUI.apk and navigate to: res/layout/status_bar.xml
3. Look for:
Code:
<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="0.33000004dip" android:layout_marginStart="5.0dip" />
Change to:
Code:
<com.android.systemui.statusbar.policy.MinitBattery android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="0.33000004dip" android:layout_marginStart="5.0dip" />
4.Download the mod files and place them in smali/com/android/systemui/statusbar/policy folder.
5.Recompile and set permissions.
You are free to use and bake this mod and app into your rom provided you give full and proper credits and you provide a link to this thread. Also you cannot alter in any way without permission from me first.
This is not a open source project and I share with you as is. All codes belong to and are copyright to me.
My wife and kids for giving up their time with me so I can do this. Love you guys.
@pas2001 for batterys, renaming icons and testing.
@*wii360* for renaming batterys and testing.
@xxmrgreenxx for renaming batterys.
@NadMaj for his battery archive.
Disclaimer: Download at your own risk. I am not responsible for any damage/data loss etc from flashing this framework.​
XDA:DevDB Information
3Minit Battery Mod, App for the Samsung Galaxy S 4
Contributors
gharrington, pas2001
Version Information
Status: Beta
Current Beta Version: 0.1
Created 2014-07-02
Last Updated 2014-07-02
hi , how can i uninstall 3minit battery mod ( it is preinstalled in the rom i use ), i tried to uninstall it using system application remover , it was uninstalled , but when i rebooted my cellphone , the UI crashed and it kept restarting .... any idea ?
Samsung Note 3 SM-N900

[Q] Mysterious Permissions! Where did they get from?

Hello! I am really going mad!! Please help me! I am developing cm11 theme using other one as a template. But now I want to change the package name of apk!
I changed it using Eclipes, signed and recompiled it. But when i install this theme, it shows me new "Privacy" permissions with 2 items (see screenshot), that were not before (when I was using template's package name, compiling it using apktool and signing it with Zipsigner).
Is it OK to have "Privacy" permissions and these 2 items? (But I dont think so..) Or how can I remove them?
In manifest there are no changes except package and author names.
Here is the code:
Code:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.my.theme">
<meta-data android:name="org.cyanogenmod.theme.name" android:value="My Theme"/>
<meta-data android:name="org.cyanogenmod.theme.author" android:value="Me"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name"/>
<uses-feature android:name="org.cyanogenmod.theme" android:required="true"/>
</manifest>
When I edit Manifest using Notepad and compile it Using Apktool I Get .apk file With 80KB.. When I edit manifest and smali folders and files, where is written package name, and compile it, I get normal apk but with old Package name!! What is the problem? Are there other ways to edit manifest?
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Nurbolat said:
Hello! I am really going mad!! Please help me! I am developing cm11 theme using other one as a template. But now I want to change the package name of apk!
I changed it using Eclipes, signed and recompiled it. But when i install this theme, it shows me new "Privacy" permissions with 2 items (see screenshot), that were not before (when I was using template's package name, compiling it using apktool and signing it with Zipsigner).
Is it OK to have "Privacy" permissions and these 2 items? (But I dont think so..) Or how can I remove them?
In manifest there are no changes except package and author names.
Here is the code:
Code:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.my.theme">
<meta-data android:name="org.cyanogenmod.theme.name" android:value="My Theme"/>
<meta-data android:name="org.cyanogenmod.theme.author" android:value="Me"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name"/>
<uses-feature android:name="org.cyanogenmod.theme" android:required="true"/>
</manifest>
When I edit Manifest using Notepad and compile it Using Apktool I Get .apk file With 80KB.. When I edit manifest and smali folders and files, where is written package name, and compile it, I get normal apk but with old Package name!! What is the problem? Are there other ways to edit manifest?
Click to expand...
Click to collapse
post the apk
I've already solved the problem The problem was in capability code in manifest

[AOSP][STOCK TW][5.0][SAMSUNG][GLOWPAD][MOD]Glowpad for stock Caller ID AOSP style

Can we ported aosp glowpad button on our stock samsung dialer android 5.0 ? Can you give an assessment as an expert please
image:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Thank you
upd i found sample of glowpad we can using it?
https://play.google.com/store/apps/details?id=net.sebastianopoggi.samples.ui.GlowPadSample
https://github.com/frakbot/GlowPadBackport
In order to use the GlowPadView in your project, follow these steps:
Ensure you have the Maven Central repository configured in your build.gradle file, eg.:
repositories {
mavenCentral()
}
This has to be in your app module's build.gradle or in the project's top-level build.gradle file. Android Studio puts it into the top-level file by default.
Add the dependency to your app's module build.gradle file, eg.:
Code:
dependencies {
// Your other dependencies...
compile 'net.frakbot.glowpadbackport:glowpadbackport:2.1.0'
}
Reference the GlowPadView in an XML layout (or initialise it from code)
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<net.sebastianopoggi.ui.GlowPadBackport.GlowPadView
android:id="@+id/incomingCallWidget"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="-10dp"
android:layout_marginBottom="-46dp"
android:background="@android:color/black"
android:visibility="visible"
android:gravity="top"
app:targetDrawables="@array/incoming_call_widget_2way_targets"
app:handleDrawable="@drawable/ic_in_call_touch_handle"
app:innerRadius="@dimen/glowpadview_inner_radius"
app:outerRadius="@dimen/glowpadview_target_placement_radius"
app:outerRingDrawable="@drawable/ic_lockscreen_outerring"
app:snapMargin="@dimen/glowpadview_snap_margin"
app:vibrationDuration="20"
app:feedbackCount="1"
app:glowRadius="@dimen/glowpadview_glow_radius"
app:pointDrawable="@drawable/ic_lockscreen_glowdot"/>
</RelativeLayout>
????
Profit!
Sample app
Click to expand...
Click to collapse
My friend finist1 make projects for aide you can using it
https://yadi.sk/d/E7xCPq8TdocFC
https://yadi.sk/d/hzZlbfa-docJq
He plug library now programmers can use it with app glowpad on full potential and take resources from it
Also this code we found in stock caller is very simmilar like glowpadsample
LegacyInCallUI\res\layout\answer_fragment.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.incallui.GlowPadWrapper android:gravity="center" android:id="@id/glow_pad_view" android:background="@android:color/black" android:focusable="true" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" dc:targetDrawables="@array/incoming_call_widget_3way_targets" dc:targetDescriptions="@array/incoming_call_widget_3way_target_descriptions" dc:directionDescriptions="@array/incoming_call_widget_3way_direction_descriptions" dc:handleDrawable="@drawable/ic_in_call_touch_handle" dc:outerRingDrawable="@android:drawable/ic_lockscreen_sim" dc:innerRadius="@dimen/glowpadview_inner_radius" dc:outerRadius="@dimen/glowpadview_target_placement_radius" dc:glowRadius="@dimen/glowpadview_glow_radius" dc:vibrationDuration="20" dc:snapMargin="@dimen/glowpadview_snap_margin" dc:feedbackCount="1" dc:allowScaling="true"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:dc="http://schemas.android.com/apk/res-auto" />
GlowPadBackport-sample-release\res\layout\main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<Button android:id="@id/btn_toggle_padmult" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/btn_toggle_multiplier" android:layout_alignParentTop="true" />
<net.sebastianopoggi.ui.GlowPadBackport.GlowPadView android:gravity="top" android:id="@id/incomingCallWidget" android:background="@android:color/black" android:visibility="visible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginTop="-10.0dip" android:layout_marginBottom="-46.0dip" android:layout_below="@id/btn_toggle_padmult" app:targetDrawables="@array/incoming_call_widget_2way_targets" app:handleDrawable="@drawable/ic_in_call_touch_handle" app:outerRingDrawable="@drawable/ic_lockscreen_outerring" app:pointDrawable="@drawable/ic_lockscreen_glowdot" app:innerRadius="@dimen/glowpadview_inner_radius" app:outerRadius="@dimen/glowpadview_target_placement_radius" app:glowRadius="@dimen/glowpadview_glow_radius" app:vibrationDuration="20" app:snapMargin="@dimen/glowpadview_snap_margin" app:feedbackCount="1" />
</RelativeLayout>
stock caller

[GUIDE]How to add Animated Splash Screen to your Android App using Android Studio

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
In this tutorial i will show you how to add simple Animated Splash Screen to your Android Application using Android Studio. You can add this Splash Screen either to existing Android Studio Project or New Android Studio Project.
Code is necessary for the implementation can be copied from here and watch the video below for the detail explanation of the implementation.
​
If you had not installed a plugin on your computer...Visit this link:​Click Here.​
Splashscreen.java
Code:
import android.app.Activity;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class Splashscreen extends Activity {
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
/** Called when the activity is first created. */
Thread splashTread;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splashscreen);
StartAnimations();
}
private void StartAnimations() {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
anim.reset();
LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
l.clearAnimation();
l.startAnimation(anim);
anim = AnimationUtils.loadAnimation(this, R.anim.translate);
anim.reset();
ImageView iv = (ImageView) findViewById(R.id.splash);
iv.clearAnimation();
iv.startAnimation(anim);
splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
// Splash screen pause time
while (waited < 3500) {
sleep(100);
waited += 100;
}
Intent intent = new Intent(Splashscreen.this,
MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
Splashscreen.this.finish();
} catch (InterruptedException e) {
// do nothing
} finally {
Splashscreen.this.finish();
}
}
};
splashTread.start();
}
}
layout/activity_splashscreen.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#242729"
android:layout_gravity="center"
android:id="@+id/lin_lay"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/splash"
android:background="@drawable/splash_img" />
</LinearLayout>
anim/alpha.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="3000" />
anim/translate.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="200%"
android:toYDelta="0%"
android:duration="2000"
android:zAdjustment="top" />
</set>
And now the last code that is for AndroidManifest.xml. Here we have to add a new activity for our java class(Splashscreen)
AndroidManifest.xml
Code:
<activity
android:name=".Splashscreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Put these code before MainActivity and change MainActivity's "android.intent.category.LAUNCHER" to "android.intent.category.DEFAULT"
Copy an image with name splash_img in png format.
So this is the simple way to add Animated Splashscreen to you Android App.
Now go to buil in top menu of Android Studio and select Generate signed Apk and epxort your Application. After Succesfull export copy it to your phone and install. Or Upload to play store.
Thanks to Karthik M
Pls hit the thanks button if i helped you:angel:
For more information-Visit: http://androidtechfreakat.blogspot.in
http://androidtechxdaat,weebly.com
http://advaitt17.github.io
All these codes are hosted with GitHub. You can visit there. The link is given in the source code.
XDA:DevDB Information
[GUIDE]How to add Animated Splash Screen to your Android App using Android Studio , App for all devices (see above for details)
Contributors
AdvaitT17, Karthik M
Source Code: https://github.com/AdvaitT17/How-to-add-Animated-Splash-Screen-to-you-Android-App-using-Android-Studio.-
Version Information
Status: Stable
Created 2016-04-02
Last Updated 2016-04-03
RESERVED

Categories

Resources