Android and android Official Website

Source: Internet
Author: User

Android and android Official Website

  • Set the title bar background

1> prepare a background image:Background_pix.png

Note: it is better to use a background image than a color image to make the background look blurred.

2> place xml files in the drawable folder

Bitmap_repeat.xml

<?xml version="1.0" encoding="utf-8"?><bitmap xmlns:android="http://schemas.android.com/apk/res/android"     android:src="@drawable/title_pic"    android:tileMode="repeat"> </bitmap>

3> define the style File style. xml

<? Xml version = "1.0" encoding = "UTF-8"?> <Resources> <! -- Customize the title style --> <style name = "StatusBarBackground"> <item name = "android: background "> @ drawable/bitmap_repeat </item> </style> <style name =" XTheme "parent =" android: Theme "> <! -- Window attributes --> <item name = "android: windowTitleBackgroundStyle"> @ style/StatusBarBackground </item> </style> <! -- Customize the title style --> </resources>

4> reference the topic android: theme = in manifest. xml"@ Style/XTheme"

<activity android:name=".activity.MainActivty"android:screenOrientation="portrait"android:configChanges="keyboardHidden|orientation"android:theme="@style/XTheme"></activity>
  • Custom title bar layout file ct_title.xml

Note: In the ct_title.xml file, setting the title bar background in the following way will result in insufficient filling.

android:background="@drawable/bitmap_repeat "
  • Reference in activity
@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);setContentView(R.layout.main);getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.ct_title);}

Reprinted please indicate the source: http://www.cnblogs.com/yydcdut/p/3694597.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.