标签:android android-layout android-resources android-styles android-theme
我想将图形布局显示的样式应用为Theme.DeviceDefault.Dialog.Alert.我知道现在这是一种私人风格,我不能把它作为父母.
如何将这种风格用于我的DialogFragment?
(我的目标是API 15,也许我想使用minSdk API 12).
这报告了一个错误(父母,就像我读的那样,现在是私人的):
<style name="MyDialogStyle" parent="@android:style/Theme.DeviceDefault.Dialog.Alert">
No resource found that matches the given name.
我只是读到我必须“复制”样式的项目,但我找不到它在哪里?
有人可以帮帮我吗?我需要将该样式“克隆”为我的自定义样式.
提前致谢.
我尝试过的事情:
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);
}
我的自定义风格
<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>
我访问了这些链接:
http://developer.android.com/reference/android/app/AlertDialog.html
http://developer.android.com/guide/topics/ui/themes.html
http://daniel-codes.blogspot.com/2011/08/new-to-android-more-style-restrictions.html
解决方法:
最后我使用Dialog而不是DialogFragment解决了这个问题,因为最后一个不支持透明度布局.很容易设置透明背景进行新活动并在Manifest中设置样式.否则,我不得不使用活动而不是片段来更改对话框的结构.
我希望这能节省许多人的研究时间.
再见!
标签:android,android-layout,android-resources,android-styles,android-theme 来源: https://codeday.me/bug/20190709/1412384.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。