相关疑难解决方法(0)

Android中的DialogFragment主题

我在android中构建我的第一个应用程序.我做了一个dialogFragment,但它看起来不够好.因为我有一个风格和主题,我用它setStyle(DialogFragment.STYLE_NORMAL,0).我想要的是片段的边缘像框架一样是黑色的,或者它的角是圆的.我想我必须在xml中编写自己的风格并将其放入样式中,但我不确定.有人能指出我正确的方向吗?感谢您的时间.

user-interface android

18
推荐指数
1
解决办法
2万
查看次数

如何设置DialogFragment的主题

有人可以解释为什么这个陈述非常有效:

setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo);
Run Code Online (Sandbox Code Playgroud)

而下一个声明没有提供

setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog);
Run Code Online (Sandbox Code Playgroud)

这就是我在风格部门所拥有的:

<style
    name="dialog">
    <!-- title encapsulating main part (backgroud) of custom alertdialog -->
    <item
        name="android:windowFrame">@null</item>
        <!-- turn off any drawable used to draw a frame on the window -->
    <item
        name="android:windowBackground">@null</item>
        <!-- turn off any drawable used to draw a frame on the window -->
    <item
        name="android:windowIsFloating">true</item>
        <!-- float the window so it does not fill the screen -->
    <item
        name="android:windowNoTitle">true</item>
        <!-- remove the title bar we make our own-->
    <item
        name="android:windowContentOverlay">@null</item>
        <!-- remove …
Run Code Online (Sandbox Code Playgroud)

android

13
推荐指数
2
解决办法
3万
查看次数

带有AppCompat主题问题的Android DialogFragment

我试图用AppCompat主题创建DialoFragment,但是当我使用AppCompat主题时,没有显示对话框标题.

我使用定义的样式:

<style name="DialogFragment" parent="Theme.AppCompat.Light.Dialog"/>
Run Code Online (Sandbox Code Playgroud)

当父主题将更改为:

<style name="DialogFragment" parent="android:Theme.Material.Light.Dialog"/>
Run Code Online (Sandbox Code Playgroud)

要么

<style name="DialogFragment" parent="android:Theme.Holo.Light.Dialog"/>
Run Code Online (Sandbox Code Playgroud)

标题显示正常.

我的对话代码:

public class InfoDialog extends DialogFragment {

    public static final String TAG = InfoDialog.class.getName();

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        dialog.getWindow().setTitle(getString(R.string.dialog_title));

        return dialog;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogFragment);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.info_dialog, container, false);
    }
}
Run Code Online (Sandbox Code Playgroud)

是什么原因引起了这个问题?应用程序使用com.android.support:appcompat-v7:22.2.0,也许这是平台错误?

android android-appcompat android-dialogfragment

10
推荐指数
2
解决办法
5258
查看次数