Skip to content

Instantly share code, notes, and snippets.

@icastell
icastell / close_hide_keyboard.java
Created April 25, 2012 14:12
How to close/hide the Android Soft Keyboard?
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
@icastell
icastell / emoji_impl.java
Created April 26, 2012 11:23
Emoji implementation
package com.mrm.emoji;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import android.content.Context;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import com.mrm.emoji.R;
public class EmoticonUtils {
@icastell
icastell / disable_home_button.java
Created May 8, 2012 14:36
Disable Home button
@Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
@icastell
icastell / adaptHeightViewWithText.m
Created October 10, 2012 15:25
Adapt the UILabel height to its content text
- (void) adaptHeightView:(UILabel *)label withText:(NSString *)text
{
// First we must to set the text into the label
[label setText:text];
// Get the label frame with the entire text
CGRect frame = [label frame];
// Get the label size
// 1. Set the label font
// 2. Add size restrictions, set the label width and put a maximun height, in this case 9999
// 3. Establish the line break mode
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
if(position>lastAnimatedPosition){
v.setRotationX(80);
v.setTranslationY(400);
v.animate()
.rotationX(0)
.translationY(0)
.setDuration(600)
@icastell
icastell / AndroidManifest.xml
Created May 26, 2013 09:55
Pushing the ActionBar to the Next Level
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cyrilmottier.android.translucentactionbar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
@icastell
icastell / themes.xml
Created May 26, 2013 10:01
Pushing the ActionBar to the Next Level
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.TranslucentActionBar" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/Widget.ActionBar</item>
</style>
<style name="Theme.TranslucentActionBar.ActionBar" />
<style name="Theme.TranslucentActionBar.ActionBar.Overlay">
<item name="android:actionBarStyle">@style/Widget.ActionBar.Transparent</item>
@icastell
icastell / styles.xml
Created May 26, 2013 10:06
Pushing the ActionBar to the next level
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/ab_background</item>
</style>
<style name="Widget.ActionBar.Transparent">
<item name="android:background">@android:color/transparent</item>
</style>
</resources>
@icastell
icastell / AndroidManifest.xml
Created May 26, 2013 10:07
Pushing the ActionBar to the next level
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cyrilmottier.android.translucentactionbar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
@icastell
icastell / NotifyingScrollView.java
Created May 26, 2013 10:11
Pushing the ActionBar to the next level
package com.cyrilmottier.android.translucentactionbar;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;
/**
* @author Cyril Mottier
*/
public class NotifyingScrollView extends ScrollView {