在Android的定制标题栏 [英] Customized Title bar in android

查看:210
本文介绍了在Android的定制标题栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个标题栏在这样的android

I want to develop a title bar in android like this


  1. 主页按钮 - 左对齐

  2. 应用程序标题 - 在中心

  3. 图片图标 - 右对齐

我不知道该怎么做。
我是一个新用户,因此不允许在这里发表的形象。对不起,inconvinience。

I am not sure how to do it. I am a new user and hence not allowed to post the image here. Sorry for inconvinience.

推荐答案

要创建一个自定义标题栏,你需要做的四件事

To create a custom title bar, you need to do four things


  1. 设置了一个相对布局指定的TextView 为左,文字和<$​​ C $ C>的ImageView 在中心对齐。

  2. 的onCreate 其中显示自定义标题的活动,呼吁 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

  3. 呼叫的setContentView 如常。

  4. 然后,你需要指导的自定义标题的布局是到位与相关的相对布局 getWindow.setFeatureInt(Window.FEATURE_CUSTOMER_TITLE,R.layout.my_custom_title);

  1. Set up a relative layout specifying TextView for left, center text, and a ImageView aligned in the centre.
  2. From the onCreate of the activity where the custom title is displayed, call requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
  3. Call setContentView as usual.
  4. Then you need to instruct that the layout of the custom title is to be put in place with the associated relative layout getWindow.setFeatureInt(Window.FEATURE_CUSTOMER_TITLE, R.layout.my_custom_title);

从那里开始,其通过获得的TextView 的ImageView 控件的问题findViewById 并调用控件的适当的方法来满足要求。

From there onwards, its a matter of obtaining the TextView and ImageView widgets via findViewById and calling the appropriate methods of the widget to suit the requirements.

这篇关于在Android的定制标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆