How to scroll/move text within TextView on home screen widget ?

by Ravi » Fri, 23 Apr 2010 08:02:10 GMT

Sponsored Links
 Hi All,

I have created a widget to be displayed on android emulator's home
screen to display some long text. In my main.xml layout file i've
already set TextView properties like singleLine="true",
ellipsize="marquee", focusable="true" etc, but still when my widget is
displayed on home screen text does not move/scroll.

----------------- main.xml layout file ------------------------

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" 
android:layout_height="wrap_content" android:background="@drawable/
<TextView android:id="@+id/widget_textview"
android:focusable="true" />

----------------- end of main.xml layout file ------------------------

------------- My file ----------------------


import android.util.Log;
import android.widget.RemoteViews;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;

public class WeatherWidget extends AppWidgetProvider{

private static final String TAG = "WeatherWidget";

public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds)
Log.d("WEATHER-WIDGET", "onUpdate(): ");

final int N = appWidgetIds.length;
// Perform this loop procedure for each App Widget that belongs to
this provider
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];

// Create an Intent to launch ExampleActivity
Intent intent = new Intent(context, Weather.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, 0);

Log.i("WEATHER-WIDGET", " Create and Attach Text-view click handler
// Get the layout for the App Widget and attach an on-click listener
to the button
RemoteViews views = new RemoteViews(context.getPackageName(),
views.setOnClickPendingIntent( , pendingIntent);

// Tell the AppWidgetManager to perform an update on the current App
appWidgetManager.updateAppWidget(appWidgetId, views);

----------------- End of WidgetProvider file--------------------

When i add widget on home screen than only some part of text is
displayed as " Latest Weather Infor" but i would like to write the
code in such a way that the complete text should scroll till the
complete string/text is displayed.

Please suggest whether i need to change my layout file or what logic i
can write so that i can scroll the text.

Thanks in advance,


Other Threads

1. Howto? identify the inflated resource

Ok, this is the same problem as my last post, but i'm not getting any 
traction with it, so i'm looking for another method solve the problem.

All i need to do is identify the xml resource a view was inflated from, in 
the views constructor.

I've tried android:tag which does not seem to be able to do it in this case 
(I only ever get null back from getTag()).

The situation is that I have a single java class extending view.
I inflate one of many XMLs into the view and I need to be able to change 
stylesheets based upon which xml resource i'm loading.

Does anyway one a method of doing this?

My last fallback is to use some sort of static class that I can set the xml 
resource on for the entire app, then try and look at the id to determine 
which resource I loaded. I'm reluctant to do that because it's kludgy and I 
think its far more likely to introduce bug etc. Note that I haven't tried to 
do this yet, but it should work based on how java behaves.

I just can't believe that there is no way to a view to know what XML 
resource it was inflated from!

- Brill Pappin


2. Turning off "save to SD Card"...problem?

What will happen if I turn off the ability to move an app to the sd
card for an app that currently has that feature? Will it just move the
app to the problems?

I asked because I turned it on not realizing some things would break
or not work consistently. REALLY need the read the docs better :)



3. Window token is always null

4. Using a bitmapdrawable to repeat an image and translate it

5. GPS turned on automatically on some devices?

6. Problem with large number of markers on google map

7. "Use wireless networks" setting not always available?