2012-07-10 66 views
4

如何设置标题和对话框内容之间的蓝色分隔线(请参见截图)?如何自定义Android ICS样式对话框中的行

我更喜欢通过xml来做到这一点,但如果有必要,我会采取一个程序化的解决方案。

我已经浏览了android-15的默认styles.xml和themes.xml,但是我找不到任何东西。

Standard Android dialog

+0

创建自定义对话框。 – AkashG 2012-07-10 07:21:47

+0

你有没有得到所需的解决方案? – AkashG 2012-07-11 09:10:14

+0

我想要做同样的事情。最后你决定了什么? – bencallis 2012-07-27 19:29:04

回答

1

如果您正在使用ActionBarSherlock你可以通过查看检查出来abs_dialog_title_holo.xml。在那里您会看到蓝线是通过视图定义的分隔线:

<View android:id="@+id/abs__titleDivider" 
     android:layout_width="fill_parent" 
     android:layout_height="2dip" 
     android:background="@color/abs__holo_blue_light" /> 
+0

谢谢。那么如果不更改ABS的某些部分,就无法对其进行定制? – benvd 2012-07-10 09:16:25

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
     android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:fitsSystemWindows="true"> 
    <TextView android:id="@android:id/title" style="?android:attr/windowTitleStyle" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:paddingLeft="16dip" 
     android:paddingRight="16dip" 
     android:gravity="center_vertical|left" 
     android:text="Dialog" 
     android:textColor="@Color/blue"/> 
    <View android:id="@+id/titleDivider" 
      android:layout_width="match_parent" 
      android:layout_height="2dip" 
      android:background="@Color/blue" /> 
    <TextView android:id="@android:id/title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingLeft="16dip" 
     android:paddingRight="16dip" 
     android:gravity="center_vertical|left" 
     android:textColor="@android:color/white" 
     android:text="Your Text"/> 
</LinearLayout> 

集此XML作为类的内容,并在清单文件中添加以下线下活动:

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 
+0

我们希望保持原生的ICS外观,只是该线条颜色不同。但我想我可以根据默认的对话框布局... – benvd 2012-07-10 09:17:25

+0

它工作吗? – AkashG 2012-07-16 05:28:10

+0

@AkashG你如何“将此xml设置为类的内容”?你指的是哪一类?请问你能提供一个编码的例子吗?如果你能帮我做到这一点,我会很乐意提出这个答案。 – PeteH 2013-09-13 08:11:45