Thursday, 9 June 2016

XML : Android widget layout blinks, appears and disappears and does weird things

I have developed an Android widget with an XML layout that I attach to this message. I have tested the widget in a Galaxy S3 and a Galaxy A5 and it works well, but in an LG L5 sometimes it does weird things. Some lines of the layout start to blink at high speed, they disappear and appear alternatively, the layout moves itself up and down... And not, I am not drug. This happens only on the LG L5 and it doesn't happen always. The major part of the time the widget works well on that device but sometimes I have the aforementioned problems. The only cause I thought about was that the layout is meant wrong. Please read this XML code to find any wrong thing I can correct. Something may be drawn wrong and be causing these problems.

  <?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:orientation="vertical" >        <TextView          android:id="@+id/service_problem"          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:padding="@dimen/widget_section_padding"          android:background="@color/service_problem"          android:text="@string/service_problem"          />        <!-- Fecha y hora -->      <RelativeLayout          android:id="@+id/datetime_container"          android:layout_width="match_parent"          android:layout_height="wrap_content" >            <LinearLayout              android:id="@+id/datetime_zone"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:orientation="horizontal"              android:padding="@dimen/widget_section_padding" >                <ImageView                  android:id="@+id/datetime_icon"                  android:layout_width="@dimen/widget_icon_size"                  android:layout_height="@dimen/widget_icon_size"                  android:layout_marginEnd="@dimen/widget_icon_right_margin"                  android:layout_marginRight="@dimen/widget_icon_right_margin"                  android:contentDescription="@string/description_datetime"                  android:src="@drawable/datetime" />                <TextView                  android:id="@+id/datetime_text"                  android:layout_width="match_parent"                  android:layout_height="wrap_content" />          </LinearLayout>            <ImageView              android:id="@+id/datetime_background"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:layout_alignBottom="@id/datetime_zone"              android:contentDescription="@string/description_datetime"              android:src="@drawable/section_background" />      </RelativeLayout>        <RelativeLayout          android:id="@+id/datetime_whatsapp"          android:layout_width="match_parent"          android:layout_height="@dimen/widget_margin_between_sections" />        <!-- WhatsApp -->      <RelativeLayout          android:id="@+id/whatsapp_container"          android:layout_width="match_parent"          android:layout_height="wrap_content" >            <LinearLayout              android:id="@+id/whatsapp_zone"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:orientation="horizontal"              android:padding="@dimen/widget_section_padding" >                <ImageView                  android:id="@+id/whatsapp_icon"                  android:layout_width="@dimen/widget_icon_size"                  android:layout_height="@dimen/widget_icon_size"                  android:layout_marginEnd="@dimen/widget_icon_right_margin"                  android:layout_marginRight="@dimen/widget_icon_right_margin"                  android:contentDescription="@string/description_whatsapp"                  android:src="@drawable/whatsapp" />                <TextView                  android:id="@+id/whatsapp_text"                  android:layout_width="match_parent"                  android:layout_height="wrap_content" />          </LinearLayout>            <ImageView              android:id="@+id/whatsapp_background"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:layout_alignBottom="@id/whatsapp_zone"              android:contentDescription="@string/description_whatsapp"              android:src="@drawable/section_background" />      </RelativeLayout>        <RelativeLayout          android:id="@+id/whatsapp_calendar"          android:layout_width="match_parent"          android:layout_height="@dimen/widget_margin_between_sections" />        <!-- Calendar -->      <RelativeLayout          android:id="@+id/calendar_container"          android:layout_width="match_parent"          android:layout_height="wrap_content" >            <LinearLayout              android:id="@+id/calendar_zone"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:orientation="horizontal"              android:padding="@dimen/widget_section_padding" >                <ImageView                  android:id="@+id/calendar_icon"                  android:layout_width="@dimen/widget_icon_size"                  android:layout_height="@dimen/widget_icon_size"                  android:layout_marginEnd="@dimen/widget_icon_right_margin"                  android:layout_marginRight="@dimen/widget_icon_right_margin"                  android:contentDescription="@string/description_calendar"                  android:src="@drawable/calendar" />                <LinearLayout                  android:id="@+id/calendar_rows"                  android:layout_width="match_parent"                  android:layout_height="wrap_content"                  android:orientation="vertical" />          </LinearLayout>            <ImageView              android:id="@+id/calendar_background"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:layout_alignBottom="@id/calendar_zone"              android:contentDescription="@string/description_calendar"              android:src="@drawable/section_background" />      </RelativeLayout>        <RelativeLayout          android:id="@+id/calendar_calls"          android:layout_width="match_parent"          android:layout_height="@dimen/widget_margin_between_sections" />        <!-- Calls -->      <RelativeLayout          android:id="@+id/calls_container"          android:layout_width="match_parent"          android:layout_height="wrap_content" >            <LinearLayout              android:id="@+id/calls_zone"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:orientation="horizontal"              android:padding="@dimen/widget_section_padding" >                <ImageView                  android:id="@+id/calls_icon"                  android:layout_width="@dimen/widget_icon_size"                  android:layout_height="@dimen/widget_icon_size"                  android:layout_marginEnd="@dimen/widget_icon_right_margin"                  android:layout_marginRight="@dimen/widget_icon_right_margin"                  android:contentDescription="@string/description_calls"                  android:src="@drawable/calls" />                <TextView                  android:id="@+id/calls_text"                  android:layout_width="match_parent"                  android:layout_height="wrap_content" />          </LinearLayout>            <ImageView              android:id="@+id/calls_background"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:layout_alignBottom="@id/calls_zone"              android:contentDescription="@string/description_calls"              android:src="@drawable/section_background" />      </RelativeLayout>        <RelativeLayout          android:id="@+id/calls_sms"          android:layout_width="match_parent"          android:layout_height="@dimen/widget_margin_between_sections" />        <!-- SMS -->      <RelativeLayout          android:id="@+id/sms_container"          android:layout_width="match_parent"          android:layout_height="wrap_content" >            <LinearLayout              android:id="@+id/sms_zone"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:orientation="horizontal"              android:padding="@dimen/widget_section_padding" >                <ImageView                  android:id="@+id/sms_icon"                  android:layout_width="@dimen/widget_icon_size"                  android:layout_height="@dimen/widget_icon_size"                  android:layout_marginEnd="@dimen/widget_icon_right_margin"                  android:layout_marginRight="@dimen/widget_icon_right_margin"                  android:contentDescription="@string/description_sms"                  android:src="@drawable/sms" />                <TextView                  android:id="@+id/sms_text"                  android:layout_width="match_parent"                  android:layout_height="wrap_content" />          </LinearLayout>            <ImageView              android:id="@+id/sms_background"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:layout_alignBottom="@id/sms_zone"              android:contentDescription="@string/description_sms"              android:src="@drawable/section_background" />      </RelativeLayout>        <RelativeLayout          android:id="@+id/sms_notes"          android:layout_width="match_parent"          android:layout_height="@dimen/widget_margin_between_sections" />        <!-- Notes -->      <RelativeLayout          android:id="@+id/notes_container"          android:layout_width="match_parent"          android:layout_height="wrap_content" >            <LinearLayout              android:id="@+id/notes_zone"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:orientation="horizontal"              android:padding="@dimen/widget_section_padding" >                <ImageView                  android:id="@+id/notes_icon"                  android:layout_width="@dimen/widget_icon_size"                  android:layout_height="@dimen/widget_icon_size"                  android:layout_marginEnd="@dimen/widget_icon_right_margin"                  android:layout_marginRight="@dimen/widget_icon_right_margin"                  android:contentDescription="@string/description_notes"                  android:src="@drawable/notes" />                <TextView                  android:id="@+id/notes_text"                  android:layout_width="match_parent"                  android:layout_height="wrap_content" />          </LinearLayout>            <ImageView              android:id="@+id/notes_background"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:layout_alignBottom="@id/notes_zone"              android:contentDescription="@string/description_notes"              android:src="@drawable/section_background" />      </RelativeLayout>    </LinearLayout>    

No comments:

Post a Comment