Wednesday, June 19, 2013

Google Now Card : XML Layout


As we can see the Google Now card is a refreshing UI to represent content with Image, text and link , so I have stolen many thing from various resources like github and here is the card finall  UI






cards_ui_layout.xml 

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dip"
    android:background="@drawable/card_background"
    android:padding="10dip" >

    <TextView
        android:id="@+id/text_head"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_margin="5dip"
        android:text="@string/heading"
        android:textSize="24sp" />

    <TextView
        android:id="@+id/text_desc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/text_head"
        android:layout_margin="5dip"
        android:ellipsize="end"
        android:maxLines="5"
        android:text="@string/lorem"
        android:textSize="14sp" />

    <LinearLayout
        android:id="@+id/seperator"
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:layout_below="@+id/text_desc"
        android:background="#C7C7C7" >
    </LinearLayout>

    <TextView
        android:id="@+id/explore_more"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/seperator"
        android:layout_marginBottom="20dip"
        android:layout_marginLeft="30dip"
        android:layout_marginRight="5dip"
        android:layout_marginTop="5dip"
        android:text="@string/explore"
        android:textColor="#ff0099cc"
        android:textSize="16sp" >
    </TextView>

    <ImageView
        android:layout_width="22dip"
        android:layout_height="22dip"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/seperator"
        android:layout_marginBottom="5dip"
        android:layout_marginLeft="2dip"
        android:layout_marginRight="5dip"
        android:layout_marginTop="5dip"
        android:src="@drawable/location_web_site" />

</RelativeLayout>


Two Images that i have used


 
 

Tuesday, December 4, 2012

Android:iPhone like two field Segment Control

Hi fellas


What would we use here is use a Toggle button from android and will apply style on it.

Step 1:

Toggle button in your xml:

  <ToggleButton
                        android:id="@+id/toggleButton"
                        style="@style/style_toggle_button"
                        android:layout_width="130dp"
                        android:layout_height="35dp"
                        android:layout_marginLeft="10dp" />



Step 2 :
Style in /Value

<style name="style_toggle_button">
        <item name="android:background">@drawable/conv_fee_toggle_drawable</item>
        <item name="android:checked">true</item>
        <item name="android:textOff"></item>
        <item name="android:textOn"></item>
        <item name="android:text"></item>
    </style>



Step 3:
conv_fee_toggle_drawable in Drawable

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/percentage" android:state_checked="true"></item>
    <item android:drawable="@drawable/fixed" android:state_checked="false"></item>
</selector>


 Thats it Just place two images percentage on from iphone and fixed on from iphone

Thursday, June 14, 2012

Android : iphone red delete button

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <gradient
        android:angle="90"
        android:centerY="0.5"
        android:endColor="#D9787F"
        android:startColor="#BD1421" />

    <stroke
        android:width="1dp"
        android:color="#3F3F3F" />

    <corners android:radius="5sp" />

    <padding
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp" />

</shape>

Tuesday, June 12, 2012

Android: Facebook profile Image to ImageView

try {
img_value = new URL("http://graph.facebook.com/"+userId+"/picture?type=large");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Bitmap mIcon1 = null;
try {
mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imageUserProfile.setImageBitmap(mIcon1);

Monday, May 7, 2012

Android Set Text Color at Runtime (Code)

So it is pretty simple..
just

Step1 . Create color.xml  under  res/values in you android project
             with color name and color code

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
          <color name="Red">#E41B17</color>
          <color name="Blue">#A5D4FE</color>
          <color name="Purple">#9172EC</color>
    </resources>

Step 2 . Now in your activity

        txRed.setTextColor(getResources().getColor(R.color.Red));
        txBlue.setTextColor(getResources().getColor(R.color.Blue));
        txPurple.setTextColor(getResources().getColor(R.color.Purple));

Wednesday, May 2, 2012

Generating Key for Android Map view

This is for windows users

Step 1. Open CMD

Step 2  run  cd   C:\Program Files\Java\jdk1.5.0_10\bin   (please check your java version)

Step 3 now run the following command
         
keytool -list -keystore "C:/Documents and Settings/<"your user name here">/.android/debug.keystore"

Step 4 It will ask for password press enter leave it blank

Step 5 the certificate's MD5 fingerprint will be generated copy it
 
Step 6 Go to the following link
       Google Maps Signup Page
                    
                
Step 7 paste you MD5 fingerprint here and click on generate API Key

Tuesday, March 27, 2012

Android Reboot to recovery if volume buttons are not working

Step 1. Power Off your android phone
Step 2. Open FastBoot (for eg. in HTC Desire press Back and Power Button )
Step 3. Open CMD on your windows machine, move to sdk/platform-tools. where adb and fastboot exe are  
            present
Step 4. Run the following command
                   
                                fastboot oem gencheckpt

Done ! your phone will reboot to recovery

Source :XDA