2013-10-21 101 views
0

我創建了一個簡單的評級對話框,擴展爲FragmentDialog。下面的結果:FragmentDialog中的按鈕樣式

enter image description here

但我想獲得一個樣式一樣,在一個典型的對話框中使用android系統中

enter image description here

使用的按鍵我如何才能獲得這樣的結果?

+0

爲什麼不使用常規AlertDialog並將請求的評級佈局設置爲其內容視圖?在AlertDialog中,你可以使用setButton()函數,該按鈕看起來就像你附加的第二個圖像。 –

+0

因爲Android文檔通常會鼓勵使用FragmentDialog和Fragment。 – GVillani82

回答

1
<View 
     android:id="@+id/divider" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:layout_above="@+id/submit_layout" 
     android:layout_alignParentBottom="false" 
     android:background="?android:attr/listDivider" /> 

    <LinearLayout 
     android:id="@+id/submit_layout" 
     style="@style/ButtonBar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:descendantFocusability="beforeDescendants" 
     android:gravity="center_vertical" 
     android:minHeight="48dp" 
     android:orientation="vertical" > 

     <Button 
      android:id="@+id/reload_btn" 
      style="@style/ButtonBarButton" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/selectable_item_background" 
      android:minHeight="48dp" 
      android:text="Submit" /> 
    </LinearLayout> 

和 「selectable_item_background.xml」:在您的自定義佈局應該做的伎倆DialogFragment和使用TextViews而不是兩個按鈕

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/item_pressed" android:state_pressed="true" /> 
    <item android:drawable="@drawable/item_focused" android:state_focused="true" /> 
    <item android:drawable="@drawable/item_focused" android:state_selected="true" /> 
    <item android:drawable="@android:color/transparent" /> 
</selector> 
1

供應STYLE_NO_FRAME到的方法SetStyle(INT,INT) 。