F
F
fanhypermax2018-11-16 11:21:43
Java
fanhypermax, 2018-11-16 11:21:43

How to scroll in a widget?

ilSHcwq1RzaxK7iDbK_kbQ.png

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#09C"
android:padding="@dimen/widget_margin">
    
<TextView
    android:id="@+id/widget_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_margin="8dp"
    android:background="#09C"
    android:contentDescription="@string/appwidget_text"
    android:textColor="#ffffff"
    android:textSize="24sp"
    android:textStyle="bold|italic" />

</RelativeLayout>

public class AppWidget extends AppWidgetProvider {

    static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
       int appWidgetId) {

            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.app_widget);

            views .setTextViewText("Chefirovka is a large village not far from Tula. The people who live in Chefirovka grow vegetables and various kinds of fruit. They have domestic animals: cows, pigs, sheep, goats and even horses. You can see poultry there — hens, cocks, ducks, geese and turkeys. So they try to have everything they need to live well.");

            appWidgetManager.updateAppWidget(appWidgetId, views);

    }

}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
illuzor, 2018-11-18
@fanhypermax

Try a ListView with one item.

E
Egor, 2018-11-16
@RATlius

As with any other markup: put your TextView in a NestedScrollView

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question