wendigo
wendigo

Reputation: 1993

Using private styles (No resource found that matches the given name)

I want to apply a style like the Graphical Layout shows as Theme.DeviceDefault.Dialog.Alert. I know that it's a private style now, and I can't take it as parent.

What can I do to have that style to my DialogFragment?

(I'm targeting API 15, and maybe I want to minSdk API 12).

This reports me an error (the parent, like I read, it's private now):

<style name="MyDialogStyle" parent="@android:style/Theme.DeviceDefault.Dialog.Alert">

No resource found that matches the given name.

I just read that I must "copy" the items of style, but I don't find where is it?

Could anyone help me, please? I need to "clone" that style to my custom style.

Thanks in advance.

Things I have tried:

Hardcoded background for DialogFragment

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0));

    return super.onCreateView(inflater, container, savedInstanceState);
}

My Custom Style

<style name="MyDialogStyle">    
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

I have visited these links:

http://developer.android.com/reference/android/app/AlertDialog.html http://developer.android.com/guide/topics/ui/themes.html

http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=18659

No resource found that matches the given name '@android:style/AlertDialog' error after the latest android 3.2 sdk update

http://daniel-codes.blogspot.com/2011/08/new-to-android-more-style-restrictions.html

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml

https://android.googlesource.com/platform/frameworks/base/+/d11e6151fe88314505fa7adca6278de2e772b11c/core/res/res/values/themes_device_defaults.xml

Upvotes: 4

Views: 4631

Answers (1)

wendigo
wendigo

Reputation: 1993

Finally I solved this problem with a Dialog instead a DialogFragment because this last one doesn't support transparency layout. It was easy set the transparent background making a new activity and set the style in Manifest. Otherwise I had to change the structure of dialogs using activities instead fragments.

I hope this saves someone many hours of research.

Bye!

Upvotes: 1

Related Questions