对话框中的样式titleDivider [英] Styling titleDivider in Dialog

查看:150
本文介绍了对话框中的样式titleDivider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在Dialog中摆脱(或更改颜色)titleDivider。在蜂巢+设备上显示的对话框标题下方是一条蓝线。





我猜这是SDK的相关版面,但由于没有样式属性,我不知道如何设计样式。如果我尝试使用findViewById没有android.R.id.titleDivider

 < LinearLayout xmlns :android =http://schemas.android.com/apk/res/android
android:orientation =vertical
android:fitsSystemWindows =true>
< TextView android:id =@ android:id / titlestyle =?android:attr / windowTitleStyle
android:layout_width =match_parent
android:layout_height =wrap_content
android:minHeight =@ android:dimen / alert_dialog_title_height
android:paddingLeft =16dip
android:paddingRight =16dip
android:gravity =center_vertical |左/>
<查看android:id =@ + id / titleDivider
android:layout_width =match_parent
android:layout_height =2dip
android:background =@ android:color / holo_blue_light/>
< FrameLayout
android:layout_width =match_parentandroid:layout_height =wrap_content
android:layout_weight =1
android:orientation =vertical
android:foreground =?android:attr / windowContentOverlay>
< FrameLayout android:id =@ android:id / content
android:layout_width =match_parent
android:layout_height =match_parent/>
< / FrameLayout>
< / LinearLayout>

我已经尝试覆盖dialogTitleDecorLayout,它只引用我的theme.xml中的dialog_title_holo.xml,但是没有成功。错误是:


错误:错误:找不到符合给定名称的资源:attr
'dialogTitleDecorLayout'。



解决方案

我使用DialogFragment.STYLE_NO_TITLE主题解决了这个问题,然后在对话框布局中伪装了标题栏。 / p>

I am wondering how it is possible to get rid of (or change color) titleDivider in Dialog. It is a blue line below dialog title shown on honeycomb+ devices.

I guess this is relevant piece of layout from SDK, but since there is no style attribute I dont know how to style it. If i try with findViewById there is no android.R.id.titleDivider

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:fitsSystemWindows="true">
    <TextView android:id="@android:id/title" style="?android:attr/windowTitleStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="@android:dimen/alert_dialog_title_height"
        android:paddingLeft="16dip"
        android:paddingRight="16dip"
        android:gravity="center_vertical|left" />
    <View android:id="@+id/titleDivider"
            android:layout_width="match_parent"
            android:layout_height="2dip"
            android:background="@android:color/holo_blue_light" />
    <FrameLayout
        android:layout_width="match_parent" android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:foreground="?android:attr/windowContentOverlay">
        <FrameLayout android:id="@android:id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
</LinearLayout>

I have tried to override dialogTitleDecorLayout which is only reference to dialog_title_holo.xml in my theme.xml, but without success. Error is:

error: Error: No resource found that matches the given name: attr 'dialogTitleDecorLayout'.

解决方案

I solved the issue by using DialogFragment.STYLE_NO_TITLE theme and then faking title bar in dialog layout.

这篇关于对话框中的样式titleDivider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆