소프트 키보드가 나타나면 화면을 위로 스크롤 할 수 있도록 ScrollView를 실험하고 있습니다. 아주 간단한 프로그램으로 시작했습니다. AndroidLauncher.java에서 ScrollView와 gameView를 만들었습니다. gameView를 ScrollView에 추가하고 "setContentView (scrollView)"로 끝냈습니다.libGdx gameView가 ScrollView에 표시되지 않습니다.
음 ... 오류가없고 프로그램이 시작되고 화면에 표시되지만 프로그램에 gameView가 표시되지 않습니다. 내가 보는 모든 것은 ScrollView의 배경색입니다.
필자는 코드에 System.out.println ("Test")을 2 개, AndroidLauncher.java의 끝에 하나, MyGdxGame.java에 하나를 넣었다. AndroidLauncher.java의 테스트 만 인쇄됩니다. 즉, gameView가 만들어지지 않습니다. 누구나 아이디어가 있습니까?
AndroidLauncher.java :
덕분에 여기
코드입니다public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
ScrollView scrollView = new ScrollView(this);
ScrollView.LayoutParams fParams = new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT,
ScrollView.LayoutParams.MATCH_PARENT);
scrollView.setLayoutParams(fParams);
scrollView.setBackgroundColor(0xffa3b8fe);
View gameView = initializeForView(new MyGdxGame(), config);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
gameView.setLayoutParams(params);
scrollView.addView(gameView);
setContentView(scrollView);
System.out.println("Test 1");
}
MyGdxGame.java :
public class MyGdxGame extends Game {
SpriteBatch batch;
AssetManager assets;
@Override
public void create() {
batch = new SpriteBatch();
assets = new AssetManager();
System.out.println("Test 2");
this.setScreen(new LoadingScreen(this));
}
@Override
public void render() {
super.render();
}
public void dispose() {
batch.dispose();
}
의 AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.scroll.test.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/GdxTheme" >
<activity
android:name="com.scroll.test.android.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>