Android, at the beginning of the custom title bar encountered some problems, because many do not understand, spent a lot of time to solve.
Okay, nonsense. No, just the question:
Styles.xml
<name= "Apptheme" parent= "Android:Theme.Holo"> < style >
The topics in the above-mentioned files are used in my androidmanifest.xml:
< Application Android:allowbackup = "true" android:icon= "@mipmap/ic_launcher" android:label= "@string/app_name" android:theme= "@style/apptheme"> ... < Application >
When the program finishes writing, the runtime throws such an exception:
Java.lang.RuntimeException:Unable to start activity componentinfo{com.czj.webo/com.czj.webo.mainactivity}:
Android.util.AndroidRuntimeException:You cannot combine custom titles with other title features (You can't combine custom headings with other title features) and it probably means that there are two or more title bars that are causing the conflict.
The code above is posted because this is the cause of the program crash. Through various search data, found that the cause of the error is the use of the theme "Android:theme." holo", change it to
"Android:Theme.Light" would be OK. But don't think it's going to solve the problem, and the new question is coming.
Custom title bar Some of the default property values are not what we want, so we need to set some basic properties on the custom title bar, by Styles.xml
<stylename= "Customwindowtitlebackground"> <Itemname= "Android:background">#FFFAFA</Item> </style> <stylename= "Test"Parent= "Android:Theme.Light"> <Itemname= "Android:windowtitlesize">55dp</Item> <Itemname= "Android:background">#FFFAFA</Item> <Itemname= "Android:windowtitlebackgroundstyle">@style/customwindowtitlebackground</Item> </style>
You can then refer to the topic in the corresponding activity of androidmanifest.xml.
As follows:
Android Custom title bar