3
是否可以在Android中使用Min3d框架完成的可動態三維動畫的底部插入一個按鈕。我有一個正在旋轉的3d模型車。我想在這個工作動畫屏幕的底部放一個按鈕。是否有可能,因爲我沒有使用任何佈局。請用一個例子來解釋我,以便我可以複製我的程序。我們可以在min3d屏幕內嵌入按鈕嗎?
是否可以在Android中使用Min3d框架完成的可動態三維動畫的底部插入一個按鈕。我有一個正在旋轉的3d模型車。我想在這個工作動畫屏幕的底部放一個按鈕。是否有可能,因爲我沒有使用任何佈局。請用一個例子來解釋我,以便我可以複製我的程序。我們可以在min3d屏幕內嵌入按鈕嗎?
是的。相反,該過程是使用glSurfaceView將min3d框架添加到佈局。以下cocde強調了如何實現相同,假設您已經涵蓋了其他基礎知識(如加載對象)。如果不是,在本簡要結尾提供相同的鏈接。
//import statements
public class threedviewActivity extends RendererActivity implements View.OnClickListener,View.OnTouchListener{
//onClick and onTouch in case you want to recognize both touch and click on the button
//initialize the variables you require
@Override
public void onCreateSetContentView() {
setContentView(R.layout.activity_example);
RelativeLayout R1 = (RelativeLayout)this.findViewById(R.id.SceneHolder);
R1.addView(_glSurfaceView); //adding the min3d view into the layout
Button example_1 = (Button)this.findViewById(R.id.example_1);
Button example_2 = (Button)this.findViewById(R.id.example_2);
example_1.setOnTouchListener(this);
example_2.setOnClickListener(this);
}
public boolean onTouch(View $v, MotionEvent event) {
switch($v.getId())
{
case R.id.example_1:
//Your actions and things to do
case R.id.example_2:
//your code
}
}
public void onClick(View $v)
{
//similar to above
}
public void initScene()
{
//initialize object and other activities related to the 3d container
}
@Override
public void updateScene()
{
//update effects such as rotation on the object here, based on the button click or touch, etc.
}
}
而且包含佈局/活動應該是這個樣子的xml文件:爲了解更多關於initScene工作
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
//your data
android:id="@+id/example_1"
/>
<Button
//your data
android:id="@+id/example_2"
/>
<RelativeLayout
//nested layout which will hold the 3d container
android:id="@+id/SceneHolder">
</RelativeLayout>
</RelativeLayout>
您還可以添加額外的效果,通過點亮性玩耍,如前所述here
基本例如添加到從here拍攝的佈局。如果您希望將來使用該頁面,則同一頁面還提供了許多示例的鏈接。