0

I have tried to use this example here (AutoResizeTextView) and this example here (FontFitTextView) to resize the text in my widget.

I have a BroadcastReceiver that updates the widget and in this BroadcastReceiver I have the following. I construct the RemoteView:

AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
ComponentName thisWidget = new ComponentName(mContext, Widget.class);
RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.widget);

I then set one of the variables:

//convert to Fahrenheit if Fahrenheit selected
views.setTextViewText(R.id.wTemperature, convertTemperature(parts[4]) + "\u00B0");

I have adjusted my widget.xml accordingly to:

<uk.co.diong.weatherlive_ish.FontFitTextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textColor="#ffffff"
    android:textSize="29sp"
    android:textStyle="bold"
    android:gravity="center"
    android:text="Temp"
    android:id="@+id/wTemperature" />

But my widget now states Problem Loading Widget so now I am wondering after a few hours, will this work with RemoteViews? Both these classes extend TextView and not RemoteView.

EDIT: The LogCat has this in it:

04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method     android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 11389: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 11395: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.view.ViewGroup.onWindowSystemUiVisibilityChanged, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onWindowSystemUiVisibilityChanged
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 11397: Landroid/view/ViewGroup;.onWindowSystemUiVisibilityChanged (I)V
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0008
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 9075: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.view.ViewGroup.onRtlPropertiesChanged, referenced from method android.support.v7.widget.Toolbar.onRtlPropertiesChanged
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 11392: Landroid/view/ViewGroup;.onRtlPropertiesChanged (I)V
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0007
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 387: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 409: Landroid/content/res/TypedArray;.getType (I)I
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
Community
  • 1
  • 1
Dino
  • 561
  • 3
  • 10
  • 21

2 Answers2

1

You cannot load custom view in RemoteView.

Android Doc says, only few Layouts and Views can be load in Widget. I am afraid, resizing is not possible.

Adrian Grygutis
  • 470
  • 1
  • 8
  • 18
0

I don't know that below answer is right but just try it

The problem might be caused by com.android.support:appcompat-v7:21.0.3, on of the main dependencies required to use Android's new Layout capabilities. Try going back to the v7:20.0.0, this should solve the issue.

Found from here

https://stackoverflow.com/a/27989207/3728591

Community
  • 1
  • 1
Kirankumar Zinzuvadia
  • 1,249
  • 10
  • 17
  • I did change the **build.gradle** and all that has happend is that the logcat with those errors have gone, but I get same result with **Problem Loading Widget** I am frustrated as I have been trying this out for 4 hours. – Dino Apr 24 '15 at 13:20
  • Check this below link and try some suggested solution on there . [link](http://stackoverflow.com/questions/4952541/problem-loading-widget-message) – Kirankumar Zinzuvadia Apr 24 '15 at 13:25
  • I created a log with _Widget Loaded_ in `onEnabled` and my widget.java seems to run fine as in `onEnabled` the log _Widget Loaded_ actually displays in the LogCat and there are no other messages and I am in Verbose mode in LogCat. I also created a log in `onUpdated` which states _Entered onUpdate in Widget_ – Dino Apr 24 '15 at 13:33