2015-07-13 40 views
0

我的應用程序僅在HTC願望系列手機上的片段對話框中的白色背景上顯示白色字體。其他設備在白色背景上顯示適當的黑色字體。如何解決這個問題。請幫忙。僅在HTC願望系列對話框中的白色背景上的白色字體

private void adjustResourceLightness() { 
      // change up button to light version if using dark theme 
      int color = 0xFFFFFF; 
      getActivity().setTheme(0); 
      final Resources.Theme theme = getActivity().getTheme(); 

      if (theme != null) { 
       TypedArray backgroundAttributes = theme.obtainStyledAttributes(
         new int[]{android.R.attr.colorBackground}); 

       if (backgroundAttributes != null) { 
        color = backgroundAttributes.getColor(0, 0xFFFFFF); 
        backgroundAttributes.recycle(); 
       } 
      } 

      // convert to greyscale and check if < 128 
      if (color != 0xFFFFFF && 0.21 * Color.red(color) + 
        0.72 * Color.green(color) + 
        0.07 * Color.blue(color) < 128) { 
       mBtnNavUp.setImageResource(R.drawable.navigation_up_light); 
       mBtnCreateFolder.setImageResource(R.drawable.ic_action_create_light); 
      } 
     } 

回答

0

它與htc的錯誤。你必須使用Theme.AppCompat.Light.DarkActionBar 嘗試設置 context.setTheme(0)在調用context.getTheme()。setTo(widgetTheme)之前

+0

好吧,我會試試看。 – SANAT

+0

我使用Theme.AppCompat.Light.DarkActionBar並添加context.setTheme(0)之前調用context.getTheme()。setTo(widgetTheme),因爲你告訴,但它不工作。如果您有任何想法,請幫助我。 – SANAT

+0

我正在使用該庫進行目錄選擇:https://github.com/passy/Android-DirectoryChooser並且發生此問題。 – SANAT

相關問題