android学习笔记1:支持多种语言多种屏幕多种平台版本
来源:互联网 发布:ps cs6 for mac序列号 编辑:程序博客网 时间:2024/06/06 01:53
创建本地目录和字符串文件
MyProject/ res/ values/ strings.xml values-es/ strings.xml values-fr/ strings.xml使用字符串的方法:
// Get a string resource from your app'sResources
String hello =getResources()
.getString(R.string.hello_world);// Or supply a string resource to a method that requires a stringTextView textView = new TextView(this);textView.setText(R.string.hello_world);
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" />
使用平台样式和主题
<activity android:theme="@android:style/Theme.Dialog">
指明 Minimum 和 Target API
AndroidManifest.xml 中<uses-sdk的
minSdkVersion
和 targetSdkVersion
属性指明app的最低平台版本和最高平台版本.
<manifest xmlns:android="/apk/res/android" ... > <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" /> ...</manifest>
Tip: 在app中使用 Android Support Library 可获得更好的跨平台体验,使得新的api可以在旧版本上运行。
在运行时判断当前版本
private void setUpActionBar() { // Make sure we're running on Honeycomb or higher to use ActionBar APIs if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); }}
指明为不同屏幕创建布局和图像
MyProject/ res/ layout/ # default (portrait) main.xml layout-land/ # landscape main.xml layout-large/ # large (portrait) main.xml layout-large-land/ # large landscape main.xml
MyProject/ res/ drawable-xhdpi/ awesomeimage.png drawable-hdpi/ awesomeimage.png drawable-mdpi/ awesomeimage.png drawable-ldpi/ awesomeimage.png不同屏幕的比例
Tip: In order to provide the best features and functionality across several Android versions, you should use the Android Support Library in your app, which allows you to use several recent platform APIs on older versions.
0 0
- android学习笔记1:支持多种语言多种屏幕多种平台版本
- android支持多种屏幕
- android-支持多种屏幕[版本市场占有率] 九
- Android UI --支持多种屏幕
- Android如何支持多种屏幕
- Android如何支持多种屏幕
- Android如何支持多种屏幕
- Android如何支持多种屏幕
- android-支持多种屏幕[如何支持多种屏幕] 四
- OPhone 2.0平台支持多种屏幕尺寸
- 支持多种屏幕大小
- 支持多种屏幕
- 如何让android 支持多种屏幕尺寸
- android设备支持多种屏幕的方法
- android-支持多种屏幕[密度独立性] 三
- android-支持多种屏幕[最佳做法] 八
- android-支持多种屏幕[分组资源类型] 十
- android-支持多种屏幕[访问资源] 十五
- Easy题目总结
- UVa 12657 Boxes in a Line(双向链表的应用)
- jquerymobile动态添加元素之后不能正确渲染解决方法
- LCD驱动分析(一):时序的分析
- 音频dB值计算
- android学习笔记1:支持多种语言多种屏幕多种平台版本
- Xcode7 中文产品名不能进行真机测试(There was an internal api error) -- @shinePug
- Win7安装php7 + apache2.4,成功启动
- 个人成长杂想
- android appcompat_v7 引入出错
- xcode如何修改app的名字
- Matlab计算运行时间方法
- 设置app的图标
- 第 17 章 文本和字体