Android 自定义标题
2012-08-20 14:16
204 查看
写自定义一个布局XML文件
然后在需要自定义标题的Activity里写入如下代码
requestWindowFeature一般在setContentView之前,setFeatureInt在setContentView之后。
R.layout.menu_title为上面XML布局文件的文件名
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center_vertical" > <TextView android:id="@+id/titlebar" android:textColor="#000" android:paddingRight="5dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
然后在需要自定义标题的Activity里写入如下代码
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.menu_title); TextView titleBar = (TextView)findViewById(R.id.titlebar); titleBar.setText("欢迎你");
requestWindowFeature一般在setContentView之前,setFeatureInt在setContentView之后。
R.layout.menu_title为上面XML布局文件的文件名
相关文章推荐
- Android自定义带标题边框的Layout
- Android自定义标题时出现You cannot combine custom titles with other title features
- android 修改窗体标题的字体式样和背景图(自定义标题栏)
- android自定义带返回功能的标题
- Android 自定义ViewPager标题
- Android从SD卡中选择图片的三种方法及自定义系统选择框标题的方法
- Android之自定义(上方标题随ViewPager手势慢慢滑动)
- 自定义Android Action Bar,标题和按钮可以动态添加
- Android 自定义 标题
- Android自定义ViewGroup(二)——带悬停标题的ExpandableListView
- Android Toolbar自定义标题标题居中的实例代码
- Android Navigation Drawer,自定义ActionBar(标题居中)
- 解决android自定义标题充满的问题
- android自定义标题不能填满父控件处理方式
- Android实现自定义位置无标题Dialog
- Android ActionBar高级自定义——设置标题居中和添加控件
- android ViewPager学习(二)创建自定义标题
- android自定义标题以及全屏设置
- Android有关自定义标题的问题 You cannot combine custom titles with other title features
- android 在开发WebView时,去掉网页的标题并设置成自定义的标题