bg_repeat.xml:
<?xml version="1.0" encoding="UTF-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/bg_pattern"
android:tileMode="repeat" />
bg_pattern.jpg:
如果我以纵向模式启动应用程序:
和输出是okey。
如果在横向模式下启动应用程序,有时输出(在splashScreen BG和主要BG中)就像:
这个模式中的第二个问题(LandS):我将方向更改为纵向,然后按后退按钮关闭应用程序,刷新当前活动(1,2或甚至4次,每次按下后退btn)(刷新意味着回到当前状态)来自当前的活动!)
怎么了?这是一个错误?(每两个问题)。 bytheway我的splashScreen.java代码:
public class SplashScreen extends Activity {
private int _splashTime = 2000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
new Handler().postDelayed(new Thread(){
@Override
public void run(){
Intent mainMenu = new Intent(SplashScreen.this, NextAct.class);
SplashScreen.this.startActivity(mainMenu);
SplashScreen.this.finish();
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
}
}, _splashTime);
}
}
毕竟我说,我使用customTheme。 这是显式的xml代码:
<activity android:theme="@style/CustomTheme"
android:label="@string/app_name"
android:name=".SplashScreen">
这是styles.xml代码的一部分:
<style name="CustomTheme" parent="@android:style/Theme.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/bg_repeat</item>
</style>
但是不要测试这个新的应用程序,有没有问题。
答案 0 :(得分:0)
不重复背景是一个已知的错误,它在ICS中部分修复,完全在JB中修复。有一个解决方法,你必须在布局中包装位图,然后在onCreate中的代码中设置重复,如下所示:
parent = (RelativeLayout) findViewById(R.id.parent);
Bitmap bg = BitmapFactory.decodeResource(this.getResources(), R.drawable.bg_pattern);
BitmapDrawable patternRepeat = new BitmapDrawable(bg);
patternRepeat.setTileModeX(Shader.TileMode.REPEAT);
patternRepeat.setTileModeY(Shader.TileMode.REPEAT);
parent.setBackgroundDrawable(patternRepeat);