- 浏览: 7987142 次
- 性别:
- 来自: 广州
-
文章分类
- 全部博客 (2425)
- 软件工程 (75)
- JAVA相关 (662)
- ajax/web相关 (351)
- 数据库相关/oracle (218)
- PHP (147)
- UNIX/LINUX/FREEBSD/solaris (118)
- 音乐探讨 (1)
- 闲话 (11)
- 网络安全等 (21)
- .NET (153)
- ROR和GOG (10)
- [网站分类]4.其他技术区 (181)
- 算法等 (7)
- [随笔分类]SOA (8)
- 收藏区 (71)
- 金融证券 (4)
- [网站分类]5.企业信息化 (3)
- c&c++学习 (1)
- 读书区 (11)
- 其它 (10)
- 收藏夹 (1)
- 设计模式 (1)
- FLEX (14)
- Android (98)
- 软件工程心理学系列 (4)
- HTML5 (6)
- C/C++ (0)
- 数据结构 (0)
- 书评 (3)
- python (17)
- NOSQL (10)
- MYSQL (85)
- java之各类测试 (18)
- nodejs (1)
- JAVA (1)
- neo4j (3)
- VUE (4)
- docker相关 (1)
最新评论
-
xiaobadi:
jacky~~~~~~~~~
推荐两个不错的mybatis GUI生成工具 -
masuweng:
(转)JAVA获得机器码的实现 -
albert0707:
有些扩展名为null
java 7中可以判断文件的contenttype了 -
albert0707:
非常感谢!!!!!!!!!
java 7中可以判断文件的contenttype了 -
zhangle:
https://zhuban.me竹板共享 - 高效便捷的文档 ...
一个不错的网络白板工具
在android中,有一类布局的样式,其实是不错的,叫dashboard,中文名叫仪表板
,其实就是把很多不同的功能,都按一个个不同的图标,分别列出来,而且这些图标的间距是相等的,如下图:
[img]
http://www.androidhive.info/wp-content/uploads/2011/12/output_dashboard.png
[/img]
其核心为有一个头部header,一个中间部分,一个footer,在设计时,可以先搞个
style.xml,如下:
<resources>
<style name="ActionBarCompat">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">50dp</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@drawable/actionbar_background</item>
</style>
<style name="DashboardButton">
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:drawablePadding">2dp</item>
<item name="android:textSize">16dp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#ff29549f</item>
<item name="android:background">@null</item>
</style>
<style name="FooterBar">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">40dp</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">#dedede</item>
</style>
</resources>
然后头部的actionbar_layout.xml,可以这样写:
,其实就是把很多不同的功能,都按一个个不同的图标,分别列出来,而且这些图标的间距是相等的,如下图:
[img]
http://www.androidhive.info/wp-content/uploads/2011/12/output_dashboard.png
[/img]
其核心为有一个头部header,一个中间部分,一个footer,在设计时,可以先搞个
style.xml,如下:
<resources>
<style name="ActionBarCompat">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">50dp</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@drawable/actionbar_background</item>
</style>
<style name="DashboardButton">
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:drawablePadding">2dp</item>
<item name="android:textSize">16dp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#ff29549f</item>
<item name="android:background">@null</item>
</style>
<style name="FooterBar">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">40dp</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">#dedede</item>
</style>
</resources>
然后头部的actionbar_layout.xml,可以这样写:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/ActionBarCompat" > <ImageView android:layout_width="wrap_content" android:layout_height="fill_parent" android:clickable="false" android:paddingLeft="15dip" android:scaleType="center" android:src="@drawable/facebook_logo" /> </LinearLayout> 然后DashboardLayout.java 是GOOGLE IO提出的一个不错的程序,把应用各个图表分布均匀排列好,具体代码为:package com.androidhive.dashboard; /* * Copyright 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; /** * Custom layout that arranges children in a grid-like manner, optimizing for even horizontal and * vertical whitespace. */ public class DashboardLayout extends ViewGroup { private static final int UNEVEN_GRID_PENALTY_MULTIPLIER = 10; private int mMaxChildWidth = 0; private int mMaxChildHeight = 0; public DashboardLayout(Context context) { super(context, null); } public DashboardLayout(Context context, AttributeSet attrs) { super(context, attrs, 0); } public DashboardLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { mMaxChildWidth = 0; mMaxChildHeight = 0; // Measure once to find the maximum child size. int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec( MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST); int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST); final int count = getChildCount(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } child.measure(childWidthMeasureSpec, childHeightMeasureSpec); mMaxChildWidth = Math.max(mMaxChildWidth, child.getMeasuredWidth()); mMaxChildHeight = Math.max(mMaxChildHeight, child.getMeasuredHeight()); } // Measure again for each child to be exactly the same size. childWidthMeasureSpec = MeasureSpec.makeMeasureSpec( mMaxChildWidth, MeasureSpec.EXACTLY); childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( mMaxChildHeight, MeasureSpec.EXACTLY); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } setMeasuredDimension( resolveSize(mMaxChildWidth, widthMeasureSpec), resolveSize(mMaxChildHeight, heightMeasureSpec)); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int width = r - l; int height = b - t; final int count = getChildCount(); // Calculate the number of visible children. int visibleCount = 0; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } ++visibleCount; } if (visibleCount == 0) { return; } // Calculate what number of rows and columns will optimize for even horizontal and // vertical whitespace between items. Start with a 1 x N grid, then try 2 x N, and so on. int bestSpaceDifference = Integer.MAX_VALUE; int spaceDifference; // Horizontal and vertical space between items int hSpace = 0; int vSpace = 0; int cols = 1; int rows; while (true) { rows = (visibleCount - 1) / cols + 1; hSpace = ((width - mMaxChildWidth * cols) / (cols + 1)); vSpace = ((height - mMaxChildHeight * rows) / (rows + 1)); spaceDifference = Math.abs(vSpace - hSpace); if (rows * cols != visibleCount) { spaceDifference *= UNEVEN_GRID_PENALTY_MULTIPLIER; } if (spaceDifference < bestSpaceDifference) { // Found a better whitespace squareness/ratio bestSpaceDifference = spaceDifference; // If we found a better whitespace squareness and there's only 1 row, this is // the best we can do. if (rows == 1) { break; } } else { // This is a worse whitespace ratio, use the previous value of cols and exit. --cols; rows = (visibleCount - 1) / cols + 1; hSpace = ((width - mMaxChildWidth * cols) / (cols + 1)); vSpace = ((height - mMaxChildHeight * rows) / (rows + 1)); break; } ++cols; } // Lay out children based on calculated best-fit number of rows and cols. // If we chose a layout that has negative horizontal or vertical space, force it to zero. hSpace = Math.max(0, hSpace); vSpace = Math.max(0, vSpace); // Re-use width/height variables to be child width/height. width = (width - hSpace * (cols + 1)) / cols; height = (height - vSpace * (rows + 1)) / rows; int left, top; int col, row; int visibleIndex = 0; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } row = visibleIndex / cols; col = visibleIndex % cols; left = hSpace * (col + 1) + width * col; top = vSpace * (row + 1) + height * row; child.layout(left, top, (hSpace == 0 && col == cols - 1) ? r : (left + width), (vSpace == 0 && row == rows - 1) ? b : (top + height)); ++visibleIndex; } } }
然后,这个其实是一个布局文件的样式程序,接下来就要设计其XML,利用这个布局程序,代码如下:
fragment_layout.xml
<com.androidhive.dashboard.DashboardLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="#f8f9fe" > <!-- News Feed Button --> <Button android:id="@+id/btn_news_feed" style="@style/DashboardButton" android:drawableTop="@drawable/btn_newsfeed" android:text="News Feed" /> <!-- Friends Button --> <Button android:id="@+id/btn_friends" style="@style/DashboardButton" android:drawableTop="@drawable/btn_friends" android:text="Friends" /> <!-- Messages Button --> <Button android:id="@+id/btn_messages" style="@style/DashboardButton" android:drawableTop="@drawable/btn_messages" android:text="Messages" /> <!-- Places Button --> <Button android:id="@+id/btn_places" style="@style/DashboardButton" android:drawableTop="@drawable/btn_places" android:text="Places" /> <!-- Events Button --> <Button android:id="@+id/btn_events" style="@style/DashboardButton" android:drawableTop="@drawable/btn_events" android:text="Events" /> <!-- Photos Button --> <Button android:id="@+id/btn_photos" style="@style/DashboardButton" android:drawableTop="@drawable/btn_photos" android:text="Photos" /> </com.androidhive.dashboard.DashboardLayout>
这样就可以初步运行了,这个是核心部分,更详细的文和代码,请见:
http://www.androidhive.info/2011/12/android-dashboard-design-tutorial/发表评论
-
『Google发布移动Web性能工具PCAP Web Performance Analyzer』
2015-01-06 14:17 2275http://t.cn/RZcCwZS 最近,Google的 ... -
(收藏)在WebView中如何让JS与Java安全地互相调用
2014-11-11 09:59 894在WebView中如何让JS与Java安全地互相调用 http ... -
android中的两端对齐
2013-02-08 18:58 3178在android中的webview中,可以对文本内容进行对 ... -
jQuery Mobile十大常用技巧
2012-10-12 07:23 4298原文发表在: http://mobile.51cto.com/ ... -
Android中使用log4j
2012-10-09 20:22 18363如果要直接在android工程中使用log4j,是有点问题 ... -
收集android的三个小tip
2012-08-25 11:24 2171收集android的三个小tip 1)Android 开发中 ... -
andorid中的html.fromhtml方法
2012-08-19 21:24 8895在android中,有一个容易遗忘的Html.fromht ... -
一个不错的sencha touch MVC教程分享
2012-08-18 10:06 2891http://blog.csdn.net/fyq891014/ ... -
jquery mobile中的按钮大集合
2012-08-14 22:17 3965本文小结了jquery mobile ... -
Andrid中的plurals
2012-08-10 19:29 1782在Android中的字符串资源中,今天留意到一个很特别的东 ... -
Android中listview中的button
2012-08-08 12:56 2011在androd中的listview中,假如每一项是个buu ... -
如何有更好的Android应用创意--从一款新Android应用说起
2012-07-20 14:23 5746现在这个年头,Android ... -
android中判断网络是否连接
2012-07-12 23:19 2969在android中,如何监测网络的状态呢,这个有的时候也是十分 ... -
android中设置手机的语言系
2012-05-19 15:55 2791adb shell 进入Android的Shell,输入以下命 ... -
android 按钮设计中state_selected属性
2012-05-15 22:33 8551在android中,如果搞几个tab,然后想做到当移动到某个T ... -
android中从图库中选取图片
2012-05-11 21:03 10313在android中,如何从图库gallary中挑选图片呢, ... -
android 模拟器中启用相机API支持
2012-05-10 22:37 3214android 模拟器中启用相机支持,否则如果应用中用到相关的 ... -
(转)向android模拟器打电话发短信的简单方法
2012-04-13 13:00 2036http://blog.csdn.net/pku_androi ... -
android 中让activity全屏幕显示
2012-04-12 09:06 1703android 中让activity全屏幕显示,这是一个小ti ... -
在Android中加入GOOGLE统计系统
2012-03-31 20:43 3490Google的统计分析系统,不仅在传统WEB统计中应用很广 ...
相关推荐
在Android开发中,AChartEngine是一个非常实用的图表库,它允许开发者轻松地在应用程序中创建各种图表,如线图、柱状图、饼图以及本文提到的仪表盘。这个"Android例子源码使用AChartEngine的仪表盘"示例项目,旨在...
在这个例子中,我们将基于View类创建一个自定义仪表盘控件。 1. 创建新类:首先,创建一个新的Java类,继承自View类。例如,我们可以命名为`CustomDashboardView`。在这个类中,我们需要初始化一些基本属性,如颜色...
App Widget则是Android特有的一个特性,自Android 1.5版本开始引入,它允许开发者创建可放置在主屏幕上的小型UI元素,为用户提供便捷的服务。尽管App Widget的设计理念与Apple的Dashboard Widget和Windows的Gadget...
本项目"My_Spotify_Streamer"就是一个很好的例子,展示了如何利用Java语言在Android平台上构建一个Spotify音乐播放器。在这个项目的描述中,特别提到了需要在`MainActivityFragment.java`的第173行添加`API_ID`,这...
嵌入式八股文面试题库资料知识宝典-华为的面试试题.zip
训练导控系统设计.pdf
嵌入式八股文面试题库资料知识宝典-网络编程.zip
人脸转正GAN模型的高效压缩.pdf
少儿编程scratch项目源代码文件案例素材-几何冲刺 转瞬即逝.zip
少儿编程scratch项目源代码文件案例素材-鸡蛋.zip
嵌入式系统_USB设备枚举与HID通信_CH559单片机USB主机键盘鼠标复合设备控制_基于CH559单片机的USB主机模式设备枚举与键盘鼠标数据收发系统支持复合设备识别与HID
嵌入式八股文面试题库资料知识宝典-linux常见面试题.zip
面向智慧工地的压力机在线数据的预警应用开发.pdf
基于Unity3D的鱼类运动行为可视化研究.pdf
少儿编程scratch项目源代码文件案例素材-霍格沃茨魔法学校.zip
少儿编程scratch项目源代码文件案例素材-金币冲刺.zip
内容概要:本文深入探讨了HarmonyOS编译构建子系统的作用及其技术细节。作为鸿蒙操作系统背后的关键技术之一,编译构建子系统通过GN和Ninja工具实现了高效的源代码到机器代码的转换,确保了系统的稳定性和性能优化。该系统不仅支持多系统版本构建、芯片厂商定制,还具备强大的调试与维护能力。其高效编译速度、灵活性和可扩展性使其在华为设备和其他智能终端中发挥了重要作用。文章还比较了HarmonyOS编译构建子系统与安卓和iOS编译系统的异同,并展望了其未来的发展趋势和技术演进方向。; 适合人群:对操作系统底层技术感兴趣的开发者、工程师和技术爱好者。; 使用场景及目标:①了解HarmonyOS编译构建子系统的基本概念和工作原理;②掌握其在不同设备上的应用和优化策略;③对比HarmonyOS与安卓、iOS编译系统的差异;④探索其未来发展方向和技术演进路径。; 其他说明:本文详细介绍了HarmonyOS编译构建子系统的架构设计、核心功能和实际应用案例,强调了其在万物互联时代的重要性和潜力。阅读时建议重点关注编译构建子系统的独特优势及其对鸿蒙生态系统的深远影响。
嵌入式八股文面试题库资料知识宝典-奇虎360 2015校园招聘C++研发工程师笔试题.zip
嵌入式八股文面试题库资料知识宝典-腾讯2014校园招聘C语言笔试题(附答案).zip
双种群变异策略改进RWCE算法优化换热网络.pdf