Android如何在ScrollView中添加TextureView
我正在使用这个3D库: 我正在使用Android如何在ScrollView中添加TextureView,android,opengl-es,scrollview,opengl-es-2.0,textureview,Android,Opengl Es,Scrollview,Opengl Es 2.0,Textureview,我正在使用这个3D库: 我正在使用org.rajawali3d.surface.rajawalitexturereview,它扩展了TextureView 我想将它放在布局XML文件中的ScrollView中,但尝试这样做失败:opengl呈现的内容不可见 如果不在scrollview中使用,我可以看到内容 以下是我的XML的外观: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" andr
org.rajawali3d.surface.rajawalitexturereview
,它扩展了TextureView
我想将它放在布局XML文件中的ScrollView
中,但尝试这样做失败:opengl呈现的内容不可见
如果不在scrollview中使用,我可以看到内容
以下是我的XML的外观:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/container">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/earth_container">
<org.rajawali3d.surface.RajawaliTextureView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/earth"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="animate"
android:id="@+id/animate"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_gravity="center_horizontal" />
</RelativeLayout>
</ScrollView>
有关更多详细信息,我按照本教程尝试了前面提到的库:如果我不使用ScrollView,它工作得很好
我知道SurfaceView
不能很好地处理动画和移动(如滚动),这就是我使用TextureView
的原因。但我做错了什么?为什么我看不到我的TextureView
的内容?正如我所说,它不使用滚动视图
就可以正常工作
谢谢你的帮助 我认为您必须在创建此库/sdk的GitHub上提交此类问题。您的意思是它应该像我尝试的那样工作,这也意味着我可能在库中发现了一个bug?在这里查看我的答案:我描述了如何在相对布局上添加按钮。@BrunoBieri谢谢你,但如果你的答案是基于简单的Android XML布局的话。我试图做的是在ScrollView中实现opengl视图。请阅读我的帖子了解更多细节。谢谢
public class Activity3D extends AppCompatActivity {
private Renderer renderer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_3d);
final RelativeLayout container = (RelativeLayout) findViewById(R.id.earth_container);
final RajawaliTextureView surface = (RajawaliTextureView) findViewById(R.id.earth);
surface.setFrameRate(60.0);
surface.setRenderMode(IRajawaliSurface.RENDERMODE_WHEN_DIRTY);
renderer = new Renderer(this);
surface.setSurfaceRenderer(renderer);
findViewById(R.id.animate).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
YoYo.with(Techniques.SlideInDown)
.duration(2000)
.playOn(container);
}
});
}
}