2016-03-03 62 views
0

不工作這是我在佈局按鈕主題在DialogFragment

<android.support.v7.widget.AppCompatButton 
      android:id="@+id/positive_btn" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="50" 
      android:text="@string/submit_btn_text" 
      android:theme="@style/PrimaryRoundedButton" 
      tools:style="@style/PrimaryRoundedButton"/> 

而這裏的PrimaryRoundedButton風格

<style name="PrimaryRoundedButton" parent="Widget.AppCompat.Button.Colored"> 
    <item name="android:colorButtonNormal">@color/primary_button_color</item> 
    <item name="colorButtonNormal">@color/primary_button_color</item> 
    <item name="colorControlHighlight">@color/white</item> 
</style> 

安卓主題不能正常使用,風格的作品,但紋波當它應該是白色的時候是黃色的。相同的主題是在正常的片段中工作,但不是dialogFragment。

+0

請參閱[this](http://stackoverflow.com/questions/26422292/how-to-style-buttons-in-alert-dialog-fragment-using-material-design)文章,讓我們知道! –

+0

@SaumikBhattacharya我不使用正面/負面的按鈕,但有我自己的佈局,謝謝反正 –

回答

0

好了,所以我在我的BaseDialogFragment作爲

setStyle(STYLE_NO_FRAME, android.R.style.Theme_Light_NoTitleBar); 

設置風格我改成了

setStyle(STYLE_NO_FRAME, R.style.FullDialog); 

哪裏FullDialog是

<style name="FullDialog" parent="Theme.AppCompat.Light"> 
     <item name="android:windowNoTitle">true</item> 
     <item name="android:windowFullscreen">true</item> 
     <item name="android:windowIsFloating">false</item> 
</style> 

所以現在我有一個全屏幕的對話框帶有適當主題的按鈕。