Note that there are some explanatory texts on larger screens.

plurals
  1. POSeekBar progress update redraws whole ViewGroup
    primarykey
    data
    text
    <p>I have a view template which consists of main <code>RelativeLayout</code> and 2 <code>FrameLayouts</code> which are used for fragments.(I have attached an image to visualize my template.) Red is <code>RelativeLayout</code>, brown and green are <code>FrameLayouts</code>.</p> <p>Now, the brown part contains a very heavy but beautiful grid list. The green part contains a simple <code>LinearLayout</code> with <code>Image</code>(gray), <code>Seekbar</code>(Blue) and a <code>TextView</code>(Pink).</p> <p>The <code>SeekBar</code> progress is updated on the UI-thread every 1 second. I have noticed that ever 1 second the scrolling of the grid list freezes. By doing some traceview debugging I noticed that the list is re-drawn every 1 second. </p> <p>On top of that, I enabled "Show layout updates" option on the actual device from Developers menu. It showed even more interesting view - everything above the <code>Seekbar</code> gets redrawn. Why is SeekBar view update redraws all views above?</p> <p>I cannot show much of the code, but I do standard Fragment attachment and then create a thread in the fragment with a specific sleep period and then updating the seekbar progress on ui-thread.</p> <p>Let me know if you need any more information and I will try to update the thread. I spent like 4-5 hours today trying to understand why is it doing that - with no success...</p> <p>The main template is very simple. Something like:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bgwood" android:orientation="vertical" &gt; &lt;FrameLayout android:id="@+id/top_container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/bottom_container" /&gt; &lt;FrameLayout android:id="@+id/bottom_container" android:layout_width="match_parent" android:layout_height="300dp" android:background="#ff111111" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><img src="https://i.stack.imgur.com/CPcOv.png" alt="enter image description here"></p> <p>EDIT: Some more information...</p> <p>The bottom fragment (green) contains something like the following view structure:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/player_playercontainer" android:layout_width="fill_parent" android:layout_height="115dp" android:layout_gravity="bottom" android:background="@drawable/bg_player" android:gravity="center" android:baselineAligned="false" android:orientation="horizontal" &gt; &lt;ImageView android:layout_width="100dp" android:layout_height="100dp" android:layout_gravity="center|center_vertical" android:background="#000000" android:scaleType="fitXY" android:src="@drawable/hdd" /&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal" android:layout_weight="0.64" android:gravity="center" android:orientation="vertical" android:paddingLeft="10dp" android:paddingRight="10dp" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="5dp" android:shadowColor="#cc111111" android:shadowDx="1" android:shadowDy="1" android:shadowRadius="1" android:text="unknown" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#888" android:textSize="13dp" /&gt; &lt;ProgressBar android:id="@+id/progressBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_weight="1" android:max="100" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>Attaching fragment to the bottom layout:</p> <pre><code>if (bundle == null) { FragmentTransaction fragmentTransaction = mManager.beginTransaction(); SourceListFragment fragment = BottomFragment(); fragmentTransaction.add(R.id.bottom_container, fragment).commit(); } </code></pre> <p>Updating the seekbar in the fragment:</p> <pre><code>/* Called every 1 sec */ void updateCallback(final int progress) { getActivity().runOnUiThread(new Runnable() { public void run() { if (seekBarView == null) { seekBarView = (SeekBar) view.findViewById(R.id.progressBar); } seekBarView.setProgress() }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload