2013-10-21 102 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) 。