开发者

Android window title bar icon is causing background for list view items

开发者 https://www.devze.com 2023-02-25 09:42 出处:网络
Programmatic setting the window title bar icon is causing every list view item has tile bar icon as background.

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

Android window title bar icon is causing background for list view items

With out window title icon

Android window title bar icon is causing background for list view items

--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 them开发者_如何学运维e -->
      <!-- 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.

I think this will help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消