【发布时间】:2014-10-23 13:00:42
【问题描述】:
我在将 GLSurfaceView 放在其他布局之间时遇到了问题,事实证明 - GLSurfaceView 不可能。所以我用TextureView替换了GLSurfaceView,但是问题没有解决。
我的主要布局中有这样的结构:
<RelativeLayout android:id="@+id/mainEngineLayout"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
tools:context=".activities.MyActivity">
<com.myapplication.views.openGL.myGLTextureView
android:id="@+id/myGLTextureView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="66dp"
android:layout_marginRight="66dp"/>
<LinearLayout
android:id="@+id/leftButtonsLayout"
android:layout_height="fill_parent"
android:layout_width="66dp"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:background="#b7b8b0">
<ImageButton android:layout_width="66dp" .../>
<ImageButton android:layout_width="66dp" .../>
</LinearLayout>
<FrameLayout
android:layout_height="fill_parent"
android:id="@+id/rightLayout"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical"
android:background="#b7b8b0">
<ImageButton android:layout_width="66dp" .../>
<ImageButton android:layout_width="66dp" .../>
</FrameLayout>
</RelativeLayout>
最后我想得到如下结果:
问题是在某些设备上我遇到了根本不显示 TextureView 的问题,因此左右布局之间存在黑场。
例如,它可以在我的三星 S3 和模拟器中运行,但不能在 Xperia 上正常运行。 我认为原因可能是不同的主题,但我在清单文件中设置了主题,例如:
<application
android:allowBackup="true"
android:configChanges="orientation|screenSize"
android:theme="@style/CustomHoloThemeNoActionBar"
android:screenOrientation="sensorLandscape"
android:largeHeap="true">
<activity
android:theme="@style/CustomHoloThemeNoActionBar"
在哪里"CustomHoloThemeNoActionBar" parent="@android:style/Theme.Holo.Light"
您能否告知可能导致此类问题的原因?
【问题讨论】:
-
我认为你可以使用 android:layout_toRightOf 来让你的布局正确...和 android:layout_toLeftOf 让你的布局左...。用花药布局 id 替换点
-
在使用 layout_toRightOf 和 layout_toLeftOf 的情况下,我必须将 myGLTextureView 放置在我不需要的“左”和“右”布局之后,我希望将 TextureView 作为第一个布局,例如背景。
-
android:gravity="center"
-
这个不错的链接会帮助你sandipchitale.blogspot.in/2010/05/…
-
@minafawzy 为什么您认为不喜欢使用“dp”值?我认为“dp”的意思是“与密度无关的像素”,它假设尺寸不取决于显示密度。
标签: android android-layout glsurfaceview textureview