How to show one layout on top of the other programmatically in my case?

Use a FrameLayout with two children. The two children will be overlapped. This is recommended in one of the tutorials from Android actually, it’s not a hack… Here is an example where a TextView is displayed on top of an ImageView: <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent”> <ImageView android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:scaleType=”center” android:src=”https://stackoverflow.com/questions/6690530/@drawable/golden_gate” /> <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginBottom=”20dip” … Read more

play youtube video in WebView

You cannot show them embedded except perhaps on devices that have Flash. However, if you can parse out the YouTube video details, you may be able to construct an ACTION_VIEW Intent that will show them on the YouTube application…for those Android devices that have the YouTube application. You might also experiment with HTML5’s <video> tag, … Read more

How to add multiple widgets in the same app?

You need a receiver definition for each type in your manifest file like: <receiver android:name=”.MyWidget” android:label=”@string/medium_widget_name”> <intent-filter> <action android:name=”android.appwidget.action.APPWIDGET_UPDATE” /> </intent-filter> <meta-data android:name=”android.appwidget.provider” android:resource=”@xml/medium_widget_provider” /> </receiver> <receiver android:name=”.MyWidget” android:label=”@string/large_widget_name”> <intent-filter> <action android:name=”android.appwidget.action.APPWIDGET_UPDATE” /> </intent-filter> <meta-data android:name=”android.appwidget.provider” android:resource=”@xml/large_widget_provider” /> </receiver> This would allow you to have the same AppWidgetProvider class be used for multiple widgets, with … Read more

How to make a smaller RatingBar?

How to glue the code given here … Step-1. You need your own rating stars in res/drawable … Step-2 In res/drawable you need ratingstars.xml as follow … <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:id=”@android:id/background” android:drawable=”@drawable/star_empty” /> <item android:id=”@android:id/secondaryProgress” android:drawable=”@drawable/star_empty” /> <item android:id=”@android:id/progress” android:drawable=”@drawable/star” /> </layer-list> Step-3 In res/values you need styles.xml as follow … <?xml … Read more

Change CalendarView style

In my project I defined the attribute “android:calendarViewStyle” in my theme. <style name=”Theme.Custom” parent=”@android:Theme”> <item name=”android:calendarViewStyle”>@style/Widget.CalendarView.Custom</item> </style> <style name=”Widget.CalendarView.Custom” parent=”android:Widget.CalendarView”> <item name=”android:focusedMonthDateColor”>@color/cs_textcolor</item> <item name=”android:weekNumberColor”>@color/red</item> <item name=”android:weekDayTextAppearance”>@style/TextAppearance.Medium</item> <item name=”android:dateTextAppearance”>@style/TextAppearance.Medium</item> </style> All styles possibilities are: @attr ref android.R.styleable#CalendarView_showWeekNumber @attr ref android.R.styleable#CalendarView_firstDayOfWeek @attr ref android.R.styleable#CalendarView_minDate @attr ref android.R.styleable#CalendarView_maxDate @attr ref android.R.styleable#CalendarView_shownWeekCount @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor @attr ref android.R.styleable#CalendarView_focusedMonthDateColor @attr … Read more

Multiple Instances Of Widget Only Updating Last widget

I had a similar problem. Just add this to your config activity, where you set your PendingIntent: Uri data = Uri.withAppendedPath( Uri.parse(URI_SCHEME + “://widget/id/”) ,String.valueOf(appWidgetId)); intent.setData(data); The variable URI_SCHEME is a String, and can be whatever you’d like.. ie – “ABCD” This causes each widget to have a unique PendingIntent.

Custom Fonts in Android

This is a simple example… create a folder in the root of your project called assets/fonts/ then paste the TTF font file (in this case Verdana.ttf). Then, if you want to apply that font to, say a TextView, do the following: import android.graphics.Typeface; public class FontSampler extends Activity { @Override public void onCreate(Bundle icicle) { … Read more