Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6991243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:28:19+00:00 2026-05-27T19:28:19+00:00

For some reason that I don’t understand, when I create my SurfaceView from an

  • 0

For some reason that I don’t understand, when I create my SurfaceView from an XML layout the surface is cleared every refresh. But if I just initalize it in code without the XML the drawn surface is retained.

If I initialize the SurfaceView like this it is drawn blank every refresh:

app = (App) findViewById(R.id.app);
app.setActivity(this);

If I initialize the SurfaceView like this the surface’s drawing is retained every refresh:

app = new App(this);
setContentView(app);
app.setActivity(this);

Here is the XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/black"
    android:clickable="true">
        <com.threedtopo.someapp.android.app
            android:id="@+id/app"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@android:color/black"
            android:clickable="true" />
</LinearLayout>

Any insight would be appreciated, thanks!

Edit: This is how the root view is being initialized in the first example:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
        <LinearLayout
            android:layout_alignParentTop="true"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <!-- <TextView -->
            <EditText
            android:id="@+id/hidden_text"
            android:inputType="textLongMessage"
            android:autoText="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:editable="true"
            android:visibility="gone"
            android:focusable="true"
            android:focusableInTouchMode="true"
            />
        </LinearLayout>
    <ViewSwitcher
        android:id="@+id/switcher"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <ImageView
            android:id="@+id/splash"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/splashscreen" />
        <com.threedtopo.someapp.android.app             android:id="@+id/app"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@android:color/white"
            android:clickable="true" />
    </ViewSwitcher> 
    <LinearLayout
        android:id="@+id/keyboard_layout"
        android:layout_alignParentBottom="true"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content">
        <android.inputmethodservice.KeyboardView
            android:id="@+id/keyboard"
            android:visibility="gone"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_weight="0" />
    </LinearLayout>
</RelativeLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:28:20+00:00Added an answer on May 27, 2026 at 7:28 pm

    Thanks to harism this has been solved. Apparently setting the background property in the XML file causes the SurfaceView to be cleared each draw.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason i don't like any of the themes that are on the
For some reason the Joomla docs are not very friendly to people that don't
Can I simply use if(myString == nil) For some reason a string that I
For some reason I have always assumed that most of the time a variable
For some reason this program is saying that 'switch' is not defined. What is
For some reason the Windows command prompt is special in that you have to
For some reason one installation of Moodle 1.9.3+ has a problem that file.php returns
Let's say that for some reason you need to write a macro: MACRO(X,Y) .
For some reason, we have a script that creates batch files to XCOPY our
For some reason, I was under the impression that it was just called Timeout,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.