android开发第二站UI布局(2)-----手机信息页面
来源:互联网 发布:大数据开发视频教程 编辑:程序博客网 时间:2024/04/30 13:35
1. 运行效果图
1. 设计思路(实现原理)、1)将准备好的八个图标复制到res/drawable文件夹下
2)创建一个垂直的线性布局,并在线性布局中创建4个相对布局
3)在相对布局中添加相应的TextView
4)在values文件下的style.xml文件中存放抽取出来的样式
5)创建values-zh-rCN、values-en-rUS文件夹,并在文件夹中创建strings.xml文件(国际化)
2.应用知识点
本实验主要应用UI技术线性布局和相对布局、Android开发所面临的国际化问题、样式的抽取
3.具体实现
1)创建一个新项目命名为23
2)在res文件夹->layout文件夹建立新布局文件linerlayoutdemo3
3)在布局中先使用线性布局将布局方向设为竖直方向
4)在线性布局中添加四个相对布局<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/darker_gray" tools:context=".MainActivity" android:orientation="vertical"></LinearLayout>
5)在每一个RelativeLayout中分别添加两个TextvVew,<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/darker_gray" tools:context=".MainActivity" android:orientation="vertical"><RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"></RelativeLayout><RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content"></RelativeLayout><RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"></RelativeLayout><RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"></RelativeLayout></LinearLayout>
RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" /><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" />
</RelativeLayout>
6)向TextView中添加图片将找到的图片文件复制到res下的drawble文件夹下
7)将图片添加到TextView下 并设置相关属性
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
TextView style="@style/tv_style" android:layout_alignParentLeft="true" android:layout_marginLeft="10dp" android:drawableTop="@drawable/info" android:text="@string/...." />
/>
8)在values文件下的style.xml文件中存放抽取出来的样式打开style.xml文件
复制所给样式
resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
<!-- 宽 match——parent高 wrap_content-->
<style name="h_wrap_content">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<!-- 宽高都 match——parent -->
<style name="tv_style">
<item name="android:layout_width">145dp</item>
<item name="android:layout_height">90dp</item>
<item name="android:gravity">center</item>
<item name="android:paddingTop">8dp</item>
<item name="android:paddingBottom">8dp</item>
<item name="android:drawablePadding">5dp</item>
<item name="android:background">@android:color/white</item>
</style>
</resources>
9)创建values-zh-rCN、values-en-rUS文件夹,并在文件夹中创建strings.xml文件(国际化)
将app目录转换为project目录
app——>src->main->res目录下新建这两个文件夹
new->Director重命名为values-zh-rCN、values-en-rUS
10)jstring .xml复制到这两个文件中
效果
打开两个文件
分别录入
values-zh-rCN文件夹下的strings.xml文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">手机信息页面</string>
<string name="menu_settings">设置</string>
<string name="hello_world">你好,世界!</string>
<string name="_cloud">云通信</string>
<string name="_bluetooth">蓝牙</string>
<string name="_gesture">自定义手势</string>
<string name="_gps">定位</string>
<string name="_system_info">系统信息</string>
<string name="_internet">网络</string>
<string name="_language">语言设置</string>
<string name="_set_notifycation">通知栏设置</string>
</resources>
values-en-rUS文件夹下的strings.xml文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">phoneInfo</string>
<string name="menu_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="_cloud">Cloud</string>
<string name="_bluetooth">Bluetooth</string>
<string name="_gesture">Gesture</string>
<string name="_gps">Gps</string>
<string name="_system_info">SystemInfo</string>
<string name="_internet">Internet</string>
<string name="_language">Language</string>
<string name="_set_notifycation">Notifycation</string>
</resources>
此时ExeActivtiy中R为红色(解决方法
AppCompatActivity为系统自带,当style.xml未改变时无影响;若style.xml已改,则将)
将AppCompatActivity 改为Activtity)
12)点run,选择设备完成
知识点在Android模拟器上设置(通过修改语言显示)
- android开发第二站UI布局(2)-----手机信息页面
- Android UI : 手机信息页面布局
- Android UI 手机信息页面(作业)
- 实验3 Android UI(2)创建“手机信息页面”
- Android UI---手机信息页面
- Android-UI :手机信息页面
- Android UI 手机信息页面
- Android UI 手机信息页面
- Android UI手机信息页面
- Android UI手机信息页面
- Android UI 手机信息页面
- Android UI 手机信息页面
- Android UI 手机信息页面
- Android UI手机信息页面
- Android UI手机信息页面
- Android UI手机信息页面
- Android UI——手机信息页面
- 做一个Android UI手机信息页面
- 博客网站(3)-配置URL
- 华为oj初级 记票统计
- android高仿微信表情输入与键盘输入(详细实现分析)
- Groovy优势2——使用call方法
- LR(四)关联
- android开发第二站UI布局(2)-----手机信息页面
- audio标签
- 未能加载文件或程序集“MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d”或它的某一个依赖项。
- Unity3D_uGUI学习笔记(3)_Visual Component简述
- 详谈内存管理技术(三)、线程模型
- RxJava2 vs RxJava1
- 详情和概要标签
- C#---类,对象,属性,属性值,方法
- spring 配置国际化资源文件的两种方式(转)