Wednesday, 16 January 2013

Badge Effect in Android

package com.example.badge;

import android.os.Bundle;

import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView tv1 = (TextView) findViewById(R.id.textView1);
       
       
               
       
    }

  
}


activity_main.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frameLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="20dip"
        android:layout_height="20dip"
        android:layout_gravity="top|right"
        android:background="@drawable/circle"
        android:gravity="center"
        android:padding="2sp"
        android:text="5"
        android:textColor="@android:color/black"
        android:textStyle="bold" />

</FrameLayout>


Circle.xml

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

    <shape android:shape="oval"  >
        <solid android:color="@android:color/black" />
    </shape>

</item><item
    android:bottom="1dp"
    android:left="1dp"
    android:right="1dp"
    android:top="1dp">

    <shape android:shape="oval" >
        <solid android:color="@android:color/darker_gray" />
    </shape>

</item>
</layer-list>


Output

 


No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...