【Android开发】范例1-使用表格布局与线性布局实现分类工具栏
来源:互联网 发布:奔驰s600电脑编程 编辑:程序博客网 时间:2024/06/08 09:33
实现一个横屏的带有各种功能分类的主界面,效果如图:
素材:
实现代码:
MainActivity:
package com.example.test;import android.app.Activity;import android.os.Bundle;import android.view.MotionEvent;import android.view.View;import android.view.View.OnTouchListener;import android.widget.FrameLayout;public class MainActivity extends Activity { @Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);}}
res/layout/main.xml:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/tableLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android:padding="10px" android:screenOrientation="landscape" > <!-- 表格TableRow行的android:layout_weight属性均设为1, 表示这三行平均分配整个视图空间--> <!-- 第一行 --> <TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_weight="1" android:background="#FFFFEE00" > <LinearLayout android:id="@+id/linearlayout1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:layout_margin="10px" android:background="#FFFFFF"> <TextView android:id="@+id/textView1" android:text="@string/time" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" style="@style/text"/> </LinearLayout> <LinearLayout android:id="@+id/linearlayout2" android:layout_height="fill_parent" android:layout_weight="1" android:layout_margin="10px" android:background="#FFFFFF"> <ImageView android:id="@+id/imageView1" android:src="@drawable/img01" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="fill_parent"/> <ImageView android:id="@+id/imageView2" android:src="@drawable/img02" android:layout_weight="1" android:layout_marginLeft="50px" android:layout_width="wrap_content" android:layout_height="fill_parent"/> <ImageView android:id="@+id/imageView3" android:src="@drawable/img03" android:layout_weight="1" android:layout_marginLeft="50px" android:layout_width="wrap_content" android:layout_height="fill_parent"/> </LinearLayout> </TableRow> <!-- 第二行 --> <TableRow android:id="@+id/tableRow2" android:layout_width="fill_parent" android:layout_weight="1" android:background="#FFFF6600"> <LinearLayout android:id="@+id/linearlayout3" android:layout_height="fill_parent" android:layout_weight="1" android:layout_margin="10px" android:background="#FFFFFF"> <ImageView android:id="@+id/imageView4" android:src="@drawable/img04" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="fill_parent"/> <ImageView android:id="@+id/imageView5" android:src="@drawable/img05" android:layout_weight="1" android:layout_marginLeft="40px" android:layout_width="wrap_content" android:layout_height="fill_parent"/> <ImageView android:id="@+id/imageView6" android:src="@drawable/img06" android:layout_weight="1" android:layout_marginLeft="40px" android:layout_width="wrap_content" android:layout_height="fill_parent"/> </LinearLayout> <LinearLayout android:id="@+id/linearlayout4" android:layout_height="fill_parent" android:layout_weight="1" android:layout_margin="10px" android:background="#FFFFFF"> <ImageView android:id="@+id/imageView7" android:src="@drawable/img07" android:layout_weight="1" android:layout_margin="40px" android:layout_width="wrap_content" android:layout_height="fill_parent"/> <TextView android:id="@+id/textView2" android:text="刷取二维码" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_vertical" android:layout_weight="3" style="@style/text"/> </LinearLayout> </TableRow> <!-- 第三行 --> <TableRow android:id="@+id/tableRow3" android:layout_width="fill_parent" android:layout_weight="1" android:background="#CCCCCC"> <LinearLayout android:id="@+id/linearlayout5" android:layout_height="fill_parent" android:layout_weight="1" android:layout_margin="10px" android:background="#FFFFFF"> <ImageView android:id="@+id/imageView8" android:src="@drawable/img08" android:layout_marginLeft="20px" android:layout_width="wrap_content" android:layout_height="fill_parent"/> <TextView android:id="@+id/textView3" android:text="电子邮件" android:layout_marginLeft="20px" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_vertical" style="@style/text"/> </LinearLayout> </TableRow></TableLayout>
res/values/strings.xml:
<?xml version="1.0" encoding="utf-8"?><resources> <string name="app_name">test3.1</string> <string name="hello_world">Hello world!</string> <string name="action_settings">Settings</string> <string name="time">2015年3月29日17:27:00</string></resources>
res/values/styles.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="text"> <item name="android:textSize">24px</item> <item name="android:textColor">#111111</item> </style> <style name="AppBaseTheme" parent="android:Theme.Light"> </style> <style name="AppTheme" parent="AppBaseTheme"> </style></resources>转载请注明出处:http://blog.csdn.net/acmman/article/details/44754519
0 0
- 【Android开发】范例1-使用表格布局与线性布局实现分类工具栏
- Android开发记录二之线性、表格、相对布局
- 关于Android线性布局与滚动实现
- Android -- UI布局管理,相对布局,线性布局,表格布局,绝对布局,帧布局
- 【Android开发】布局管理器-线性布局
- 【Android开发】布局管理器-表格布局
- Android 布局之线性布局、相对布局、表格布局、帧布局
- 菜鸟学android(1)线性布局与相对布局
- android 中的线性布局与相对布局
- Android-使用线性布局管理器布局
- Android-布局(使用线性布局)
- 线性布局和表格布局的嵌套使用
- Android UI 实现表格布局
- android 动态实现表格布局
- 使用css实现表格布局
- Android表格布局的使用
- Android 布局2.线性布局与框架布局
- android开发4:布局管理器1(线性布局,相对布局RelativeLayout-案例)
- IDEA 设置java运行参数
- SSDB安装与python环境的使用
- Winsocket通信测试
- iOS APP网络分析之rvictl(可以捕捉除了Wifi以外的网络类型)
- Android高效编程
- 【Android开发】范例1-使用表格布局与线性布局实现分类工具栏
- ecshop各文件路径
- 设计模式和工厂模式的结合
- mysql常用操作
- PLSQL调试技巧
- 计算机图形学
- iOS打电话、发短信、发邮件功能开发
- JVM内存区域划分 EDEN SPACE、SURVIVOR SPACE、TENURED GEN
- C++中打印调用栈