android 自定义样式文件
来源:互联网 发布:php无限分类处理类 编辑:程序博客网 时间:2024/05/22 11:40
第一步:创建布局文件
<?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="48dp"
android:orientation="vertical" >
<Button
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="10dp"
android:background="@drawable/back"
android:text=" 返回"
android:textColor="#858585"
android:textSize="18dp" />
</LinearLayout>
第二步:相关属性配置(String.xml)文件中
<resources>
<string name="app_name">ezhangkong</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<style name="CustomWindowTitleBackground">
<item name="android:background">@drawable/title_style</item>
</style>
<style name="titlewindowstyle" parent="android:Theme">
<item name="android:windowTitleSize">45dp</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
</resources>
第三步:activity配置自定义样式文件
public class ZtxxActivity extends Activity {
//状态消息界面
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
//自定义样式文件
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); //自定义窗口标题的样式 注意顺序
setContentView(R.layout.activity_ztxx);
ZtxxActivity.this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.title_style);// 注意顺序
}
}
哦,千万不要忘记在androidManifest.xml文件中配置自定义样式(注意划红线代码)
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/titlewindowstyle">
<activity
android:name="com.rf.ezhangkong.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
>
</application>
- android 自定义样式文件
- 自定义file文件样式
- 文件上传自定义样式
- Android: 自定义Tab样式
- android 自定义title样式
- Android: 自定义Tab样式
- android 自定义标题样式
- Android: 自定义Tab样式
- Android自定义Toast样式
- Android-自定义Dialog样式
- Android: 自定义Tab样式
- Android 自定义Dialog样式
- android Toast 自定义样式
- android CheckBox 自定义样式
- android自定义button样式
- android 自定义样式
- Android 自定义CheckBox 样式
- android 自定义title样式
- oracle中的日志切换和检查点
- JAVA中堆和堆栈区别
- oracle添加删除重做日志成员
- Data Structures (Weiss) Chapter 5: Hash Tables without Linked Lists (quadratic probing)
- wince注册表编程(新建,读取,修改)
- android 自定义样式文件
- hdu 1714 排列2
- 链表
- oracle中添加删除重做日志文件组
- Datetime格式化大全
- WebService传递XML数据 C#DataSet操作XML 解析WebService返回的XML数据
- Linux 中直接 I/O 机制的介绍
- ubuntu 安装android 集成环境
- 了解oracle中的重做日志成员