52inc/Scoops

使用中没有效果

luxiaoming opened this issue · 2 comments

1:
在app里面初始化
// Initialize Scoop Scoop.waffleCone() .addFlavor("Default", R.style.Theme_Scoop) .addFlavor("Light", R.style.Theme_Scoop_Light) .addDayNightFlavor("DayNight", R.style.Theme_Scoop_DayNight) .addFlavor("Alternate 1", R.style.Theme_Scoop_Alt1) .addFlavor("Alternate 2", R.style.Theme_Scoop_Alt2,true) .addToppings(Toppings.getToppings()) .setSharedPreferences(PreferenceManager.getDefaultSharedPreferences(this)) .initialize();
2:使用的地方:
`public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Scoop.getInstance().apply(this);
    setContentView(R.layout.activity_main);

3:发现没有效果,查看阅读代码:发现 public void apply(Activity activity){
Flavor flavor = getCurrentFlavor(true);
if(flavor != null){
`
这里的flavor =null,导致没有走 apply(activity, flavor.getStyleResource());,使得主题设置失败。

Are you using the themes I gave in the example? or your own set of themes? If you are using R.style.Theme_Scoop and the like and don't have them defined your styles.xml resources then it's not going to work.

Please download and run the sample source code to see how everything works, or post your styles.xml or themes.xml file here so I can further help.

多谢回复,这个问题解决了。原因是这里需要将默认主题配置到activity里面。