Jack Frost

Android篇-新手笔记之安卓自定义title标题栏使用

(之前在这个坑待太久,所以在此总结分享。)

一、标题栏简介

自定义的title控件是UI常用的一个设计手法,最简单的例子如图(找了个丑一点的)

 

二、使用过程

1.(注意:那个标题栏的布局文件和那个所在的activity的布局文件是不同的!!!)先建一个你想要的标题栏的布局文件,弄成你想要的标题的布局代码,只是上面的标题栏,所以属性、大小要注意一下

2.你需要一个自定义的主题,在styles那里建立建立一个你想要的apptheme

3.记得在对应的activity里面注册你的主题(styles)最好使用默认主题,不然容易出一堆error

4.在对应的activity的java文件里面码上引用的代码

 

三、详细流程

1.标题栏布局文件tips_title,这个只是标题栏的title布局,不是activity的布局,activity的布局要另外写

2.在资源文件的styles里面声明你要的theme

如:这个基本是默认的主题了,颜色,字体可以改,但是怕出error就别改其他的太多了

 

3.在注册文件manifests那里的对应的activity那里声明你的主题

如: 最好是使用android:theme=”@style/”   这种格式,同时还要删除ide默认生成的主题apptheme之类的,不然还是报错。

 

4.最后在相应的activity的java文件那里声明引用(!!!而且要注意,使用这主题的activity是继承Activity,不是继承AppCompat!!!)

如:

 

猴,到了这里就可以获得我们想要的自定义标题栏啦!!!

图在上面,有点丑 别介意。

ok,该注意的、易出错的都尽量写详细了。

码字很辛苦,转载请注明来自JackFrost《Android篇-新手笔记之安卓自定义title标题栏使用》

8 responses to “Android篇-新手笔记之安卓自定义title标题栏使用”

  1. Saved as a favorite, I really like your blog!

  2. fapdex.com says:

    Thiѕ web site reаlly һaѕ aⅼl of tһe info I neeԀed aЬout this subject annd diⅾn’t ҝnow who tο аsk.

  3. Hi there, I discovered your site by the use of Google at the same time as looking for a comparable
    matter, your web site got here up, it seems to be good.
    I have bookmarked it in my google bookmarks.
    Hello there, just changed into alert to your blog via Google, and located that it is truly informative.
    I am going to be careful for brussels. I’ll appreciate should
    you continue this in future. A lot of folks will likely be benefited
    from your writing. Cheers!

  4. A person necessarily lend a hand to make critically articles I might state.
    That is the very first time I frequented your web
    page and so far? I surprised with the analysis you made to make this actual submit incredible.
    Magnificent task!

  5. If some one wishes expert view regarding running a blog
    then i recommend him/her to go to see this webpage, Keep up the good job.

  6. Hi, Neat post. There’s an issue with your website in internet explorer, would check this?

    IE nonetheless is the market leader and a large part of folks will miss your excellent writing due to this problem.

  7. I would like to thank you for the efforts you’ve put
    in writing this site. I’m hoping to check out the same high-grade content from you
    later on as well. In fact, your creative writing abilities has motivated me to get my own, personal website now 😉

Leave a Reply

Your email address will not be published. Required fields are marked *