Widget layout is not working

Asked

Viewed 160 times

1

I wonder why this layout is not displayed in my widget:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Main" >

<RelativeLayout
    android:orientation="vertical"
    android:id="@+id/Seg"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="5dp"
    android:background="@drawable/shape_layout" >

    <View
        android:id="@+id/view1"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="@color/vermelho" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/view1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="3dp"
        android:contentDescription="@string/todo"
        android:src="@drawable/data" />

    <ImageButton
        android:id="@+id/SaveSeg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/view1"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="5dp"
        android:background="@null"
        android:contentDescription="@string/todo"
        android:src="@drawable/edit_button" />

    <TextView
        android:id="@+id/SegView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/view1"
        android:layout_centerHorizontal="true"
        android:text="@string/seg"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/branco"
        android:textSize="28sp" />

    <TextView
        android:id="@+id/Data1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/view1"
        android:layout_alignLeft="@+id/imageView1"
        android:layout_marginBottom="4dp"
        android:layout_marginLeft="10dp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/preto" />

    <TextView
        android:id="@+id/MainS1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/view1"
        android:layout_centerHorizontal="true"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/branco"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/MainS2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/MainS1"
        android:layout_centerHorizontal="true"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/branco"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/MainS3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/MainS2"
        android:layout_centerHorizontal="true"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/branco"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/MainS4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/MainS3"
        android:layout_centerHorizontal="true"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/branco"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/MainS5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/MainS4"
        android:layout_centerHorizontal="true"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/branco"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/MainS6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/MainS5"
        android:layout_centerHorizontal="true"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/branco"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/MainS7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/MainS6"
        android:layout_centerHorizontal="true"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/branco"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/SegHorario1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/MainS1"
        android:layout_alignRight="@+id/SaveSeg"
        android:background="@drawable/shape_edit"
        android:textColor="@color/cinza"
        android:textSize="20sp"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/SegHorario2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/MainS2"
        android:layout_alignRight="@+id/SaveSeg"
        android:background="@drawable/shape_edit"
        android:textColor="@color/cinza"
        android:textSize="20sp"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/SegHorario3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/MainS3"
        android:layout_alignRight="@+id/SaveSeg"
        android:background="@drawable/shape_edit"
        android:textColor="@color/cinza"
        android:textSize="20sp"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/SegHorario4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/MainS4"
        android:layout_alignRight="@+id/SaveSeg"
        android:background="@drawable/shape_edit"
        android:textColor="@color/cinza"
        android:textSize="20sp"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/SegHorario5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/MainS5"
        android:layout_alignRight="@+id/SaveSeg"
        android:background="@drawable/shape_edit"
        android:textColor="@color/cinza"
        android:textSize="20sp"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/SegHorario6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/MainS6"
        android:layout_alignRight="@+id/SaveSeg"
        android:background="@drawable/shape_edit"
        android:textColor="@color/cinza"
        android:textSize="20sp"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/SegHorario7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/MainS7"
        android:layout_alignRight="@+id/SaveSeg"
        android:background="@drawable/shape_edit"
        android:textColor="@color/cinza"
        android:textSize="20sp"
        android:textStyle="italic" />
  </RelativeLayout>    
</LinearLayout>
  • you’ve already added to the manifesto?

  • As far as I know layouts should not be added to manifest.xml only Activity's should be.

  • I already added to the manifesto yes!

  • How you are assigning this Layout to your @Pedroigor Widget?

  • through the @xml/widget_info thus:<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"&#xA; android:configure="com.example.android.ExampleAppWidgetConfigure"&#xA; android:initialLayout="@layout/widget_layout"&#xA; android:minHeight="300dp"&#xA; android:minWidth="300dp"&#xA; android:updatePeriodMillis="86400000" />&#xA;

1 answer

1

Try to remove your View id "@+id/view1" because how we view here the view class is not listed among those of type Remoteviews and is therefore not supported by widgets apps.

  • But if I remove it I will lose all my other elements as they are positioned in a way that references this view. The best way then would be to create an "updated layout" ?

  • @Pedroigor altere de View for a supported class, for example, ImageView, or a RelativeLayout since you use this view with a background.

  • Anyway this is the least of my problems kkk, but thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.