0
何らかの理由で私が理解できないことがありましたが、XMLレイアウトからSurfaceViewを作成すると、リフレッシュするたびにサーフェスがクリアされます。しかし、XMLなしでコードで初期化すれば、描かれたサーフェスは保持されます。SurfaceViewがXMLから初期化されました
私はこのようなSurfaceViewを初期化する場合は、すべてのリフレッシュ空白描かれている。ここで
app = new App(this);
setContentView(app);
app.setActivity(this);
がある:私は表面の描画は、すべてのリフレッシュを保持している。このようSurfaceViewを初期化する場合は
app = (App) findViewById(R.id.app);
app.setActivity(this);
をXMLレイアウト:
<?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>
洞察力はありがたいです!
編集:これは、ルートビューは、最初の例では初期化されている方法である:これは解決されているharismする
<?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>
これは違いに影響する場合としない場合がありますが、後者の場合、ルート要素としてAppを割り当て、さらに背景色を指定しません。 – harism
おかげさまで、最初の例ではルートディスプレイの初期化方法を追加しました。私はすべてのXMLレイアウトから背景色を削除しようとしましたが、それは動作を変更しませんでした。 –
OK - 正しい必要があります。背景色を設定することが原因と思われます。私は、XMLファイルの変更は、私がきれいにした後でなければ何もしなかったと思います。 –