zoukankan      html  css  js  c++  java
  • Android:自定义标题栏

    现在很多的Android程序都在标题栏上都显示了一些按钮和标题,这里尝试做个实例

    在onCreate中添加:

    //自定义标题
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.main);
    //设置标题为某个layout
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);

    布局文件:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
       >
    
        <Button
            android:id="@+id/back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="上一步"
            android:textSize="18sp"
    />
    
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="标题"
            android:textSize="18sp"
            android:gravity="center"
     />
        
            <Button
            android:id="@+id/back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="下一步"
            android:textSize="18sp"
    />
    </LinearLayout>

    为避免冲突,修改:AndroidManifest.xml

    android:theme="@style/mystyle"

    style

    <style name="mystyle" parent="android:Theme">
    <item name="android:windowTitleSize">50dp</item>
    </style>
  • 相关阅读:
    3D流水线
    log4cplus 配置文件的编写
    linux下的log4cplus的安装和使用
    日志信息的编写与调用
    转C++内存池实现
    转:自定义内存池的使用
    在linux查看内存的大小
    转:C++内存池
    数组指针 和指针数组的区别
    new的三种形态
  • 原文地址:https://www.cnblogs.com/dennytao/p/5388449.html
Copyright © 2011-2022 走看看