@fanhypermax

Как сделать прокрутку в виджете?

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);

    }

}
  • Вопрос задан
  • 131 просмотр
Решения вопроса 1
iLLuzor
@iLLuzor
Java, Kotlin, Android Developer
Попробуйте ListView с одним элементом.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
RATlius
@RATlius
Разработчик Android
Как и на любой другой разметке: положите Ваш TextView в NestedScrollView
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы