2013-07-04 32 views
0

我用DialogFragments在我的遊戲對於一些彈出信息的黑色部分。它在運行Android 4.2的LG Nexus 4上運行良好,在運行2.3的Desire S上運行良好。的Android DialogFragment顯示屏幕索尼XPERIAü

但它確實不上的索尼XPERIAù正確運行(運行4)。這是發生了什麼:

black spaces under dialogfragment

它不把對話框中的屏幕上,這發生在所有其他設備的中間,但它也使我的屏幕上的對話框下方的一個大黑色款。

這裏是我的代碼:

public void ShowMessage(String title, String msg) 
{ 
    Bundle b = new Bundle(); 
    b.putString("title", title); 
    b.putString("msg", msg); 
    DialogFragment dialog = new DialogFragment_MsgBox(); 
    dialog.setArguments(b); 
    dialog.show(getSupportFragmentManager(), "msgbox"); 
} 

public class DialogFragment_MsgBox extends android.support.v4.app.DialogFragment { 

@Override 
public Dialog onCreateDialog(Bundle savedInstanceState) { 
    Bundle b = getArguments(); 
    final Dialog dialog = new Dialog(getActivity(), R.style.SetmsgDialog); 
    dialog.setContentView(R.layout.simpleokdialog); 
    if(b.containsKey("title")) 
     dialog.setTitle(b.getString("title")); 
    else 
     dialog.setTitle("Message"); 
    return dialog; 
} 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 
    View v = inflater.inflate(R.layout.simpleokdialog, container, false); 

    Bundle b = getArguments(); 
    String msg = ""; 
    if(b.containsKey("msg")) 
    { 
     msg = b.getString("msg"); 
    } 

    TextView text = (TextView)v.findViewById(R.id.bericht); 
    text.setText(msg); 


    Button iv = (Button)v.findViewById(R.id.simpleOK); 
    iv.setOnClickListener(new Button.OnClickListener() { 
     public void onClick(View v) { 
      // When button is clicked, call up to owning activity. 
      getDialog().dismiss(); 
     } 
    }); 

    // TODO Auto-generated method stub 
    return v; 
} 

}

,也需要我使用的dialogfragment風格:

<style name="SetmsgDialog"> 
     <item name="android:background">#aac6775c</item> 
     <item name="android:textColor">@android:color/white</item> 
     <item name="android:windowNoTitle">false</item> 
     <item name="android:textSize">14sp</item> 
     <item name="android:windowIsFloating">true</item> 

     <item name="android:windowTitleStyle">@style/setwindowTitleStyle</item> 
     <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> 
     <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> 
     <item name="android:backgroundDimEnabled">true</item> 
     <item name="android:gravity">left</item> 
    </style> 

什麼原因這個?任何解決方案/提示或建議這個問題?

回答

1

我終於解決了這個問題,似乎有些手機/提供商軟件在標準主題等有不同的行爲(我已經與索尼再次與文本在白色背景上者爲白色陰影看到了這一點,很討厭的,現在再次與索尼,不同的行爲)所以,如果你重載一些主題,你總是使用自己的,而不是填寫所有的變量,使用所有的變量,以期望出來!

我「忘記」:

<item name="android:windowBackground">@android:color/transparent</item> 

的量,索尼XPERIAü採用黑色,無透明性,而關係4和期望的使用透明的顏色。