[英]Android window title bar icon is causing background for list view items
Programmatic setting the window title bar icon is causing every list view item has tile bar icon as background. 以编程方式设置窗口标题栏图标会导致每个列表视图项都具有平铺栏图标作为背景。
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ball);
How can i remove the listview background image or set the window title bar icon any other way than programmatic? 如何删除列表视图背景图像或设置窗口标题栏图标除程序之外的任何其他方式?
With window title icon set 带窗口标题图标集
With out window title icon 带窗外标题图标
--UPDATE --update
<?xml version="1.0" encoding="utf-8"?>
<!-- Sets the text styles -->
<resources>
<style name="CustomWindowTitleText" parent="android:TextAppearance.WindowTitle">
<item name="android:textSize">24dip</item>
<item name="android:textColor">#ffffff</item>
<item name="android:textStyle">bold</item>
<item name="android:typeface">normal</item>
</style>
<!-- Changes the background color of the title bar -->
<style name="CustomWindowTitleBackground">
<item name="android:background">@drawable/bg_gradient_05</item>
<item name="android:paddingLeft">10dp</item>
</style>
<!-- Set the theme for the window title -->
<!-- NOTE: setting android:textAppearence to style defined above -->
<style name="CustomWindowTitle" parent="android:WindowTitle">
<item name="android:textAppearance">@style/CustomWindowTitleText</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">0</item>
<item name="android:shadowRadius">0</item>
<item name="android:shadowColor">#a0a0a0</item>
</style>
<!-- Override properties in the default theme -->
<!-- NOTE: you must explicitly the windowTitleSize property, the title bar will not re-size automatically, text will be clipped -->
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">50dip</item>
<item name="android:windowTitleStyle">@style/CustomWindowTitle</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
</resources>
Use the following code 使用以下代码
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.my_layout);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
Please be sure that you are using requestWindowFeature
before setContentView
.Here in R.layout.custom_title
use your custom title xml. 请确保在
setContentView
之前使用requestWindowFeature
在R.layout.custom_title
使用自定义标题xml。
I think this will help you. 我想这会对你有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.