`
fonter
  • 浏览: 859082 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Android实现矩形设置菜单

阅读更多

最近试着做下图的界面,源码分享,先上图看看效果吧,下面代码为白色区域。

 

 

xml Layout

 

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent" android:layout_height="fill_parent">

	<LinearLayout android:id="@+id/all_details"
		android:layout_width="fill_parent" android:layout_height="fill_parent"
		android:orientation="vertical">
		<TextView android:text="@string/settings"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_marginLeft="10px" android:id="@+id/settingsText"
			android:textSize="20sp" android:textStyle="bold" android:layout_marginBottom="10dip">
		</TextView>
		<RelativeLayout android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:orientation="horizontal"
			android:layout_gravity="center_vertical" android:background="@drawable/imagetop"
			android:layout_marginLeft="10px"
			android:layout_marginRight="10px" android:paddingLeft="10px">
			<CheckBox android:id="@+id/firewall_checkBox" android:layout_width="@android:dimen/app_icon_size"
				android:layout_height="@android:dimen/app_icon_size"
				android:layout_alignParentRight="true" android:scaleType="fitCenter"
				android:layout_gravity="center" />
			<TextView android:id="@+id/apps_name" android:layout_width="wrap_content"
				android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium"
				android:textColor="#000000" android:textSize="18dip"
				android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
				android:paddingTop="10dip" android:paddingRight="6dip"
				android:paddingLeft="6dip" android:layout_gravity="center"
				android:text="@string/firewall_switch" />


		</RelativeLayout>
		<RelativeLayout android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:orientation="horizontal"
			android:layout_gravity="center_vertical" android:background="@drawable/imagemid"
			android:layout_marginLeft="10px" 
			android:layout_marginRight="10px" android:paddingLeft="10px">
			<CheckBox android:id="@+id/call_checkBox" android:layout_width="@android:dimen/app_icon_size"
				android:layout_height="@android:dimen/app_icon_size"
				android:layout_alignParentRight="true" android:scaleType="fitCenter"
				android:layout_gravity="center" />
			<TextView android:id="@+id/apps_name" android:layout_width="wrap_content"
				android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium"
				android:textColor="#000000" android:textSize="18dip"
				android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
				android:paddingTop="10dip" android:paddingRight="6dip"
				android:paddingLeft="6dip" android:layout_gravity="center"
				android:text="@string/blockincomingcall"/>


		</RelativeLayout>
		<RelativeLayout android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:orientation="horizontal"
			android:layout_gravity="center_vertical" android:background="@drawable/imagebottom"
			android:layout_marginLeft="10px"
			android:layout_marginRight="10px" android:paddingLeft="10px">
			<CheckBox android:id="@+id/sms_checkbox" android:layout_width="@android:dimen/app_icon_size"
				android:layout_height="@android:dimen/app_icon_size"
				android:layout_alignParentRight="true" android:scaleType="fitCenter"
				android:layout_gravity="center" />
			<TextView android:id="@+id/apps_name" android:layout_width="wrap_content"
				android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium"
				android:textColor="#000000" android:textSize="18dip"
				android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
				android:paddingTop="10dip" android:paddingRight="6dip"
				android:paddingLeft="6dip" android:layout_gravity="center"
				 android:text="@string/showcalllocation"/>


		</RelativeLayout>

	</LinearLayout>
</ScrollView>

 

imagetop.xml(保存于drawable)

 

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient 
    	android:startColor="#FFFFFF" 
    	android:endColor="#CCCCCC" 
    	android:angle="270" android:centerY="0.75"
    	/>
 
    <corners android:radius="1dp"
             android:bottomRightRadius="0dp"
             android:topRightRadius="7dp"
             android:bottomLeftRadius="0dp"
             android:topLeftRadius="7dp"
             />
 
             <!-- 
    <corners android:radius="5dip" />
    -->
</shape>

 

imagemid.xml

 

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient 
    	android:startColor="#FFFFFF" 
    	android:endColor="#CCCCCC" 
    	android:angle="270" android:centerY="0.75"
    	/>

</shape>

 

imagebottom.xml

 

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient 
    	android:startColor="#FFFFFF" 
    	android:endColor="#CCCCCC" 
    	android:angle="270" android:centerY="0.75"
    	/>

    <corners android:radius="1dp"
             android:bottomRightRadius="7dp"
             android:topRightRadius="0dp"
             android:bottomLeftRadius="7dp"
             android:topLeftRadius="0dp"
             />
</shape>

 

 

 

 

 

 

  • 大小: 23 KB
分享到:
评论
8 楼 wenjiefeng 2011-11-18  
源码呢楼主,可以分享一下嘛
7 楼 王路喜 2011-08-04  
楼主,java文件对吗?
6 楼 javacn_org 2010-09-26  
源码附近分享下啊
5 楼 fonter 2010-07-16  
j2live 写道
fonter 写道
j2live 写道
我是想找实现截图中顶部和底部菜单找到这的...
发现有不少值得学习的东西哦..
不知博主能否共享下顶部和底部固定菜单的实现啊?

哈哈。介绍一个开源的代码你吧。http://code.google.com/p/mobyfactory-uiwidgets-android/这个的实现效果和我的一样,我的参考它的,里面的代码没有实上头部,你只要看明白它的代码改起来是非常容易哦。。


过去看了下对我很有用哈..
谢啦..

不客气,能帮到你我也黑皮...
4 楼 j2live 2010-07-16  
fonter 写道
j2live 写道
我是想找实现截图中顶部和底部菜单找到这的...
发现有不少值得学习的东西哦..
不知博主能否共享下顶部和底部固定菜单的实现啊?

哈哈。介绍一个开源的代码你吧。http://code.google.com/p/mobyfactory-uiwidgets-android/这个的实现效果和我的一样,我的参考它的,里面的代码没有实上头部,你只要看明白它的代码改起来是非常容易哦。。


过去看了下对我很有用哈..
谢啦..
3 楼 fonter 2010-07-16  
j2live 写道
我是想找实现截图中顶部和底部菜单找到这的...
发现有不少值得学习的东西哦..
不知博主能否共享下顶部和底部固定菜单的实现啊?

哈哈。介绍一个开源的代码你吧。http://code.google.com/p/mobyfactory-uiwidgets-android/这个的实现效果和我的一样,我的参考它的,里面的代码没有实上头部,你只要看明白它的代码改起来是非常容易哦。。
2 楼 j2live 2010-07-16  
我是想找实现截图中顶部和底部菜单找到这的...
发现有不少值得学习的东西哦..
不知博主能否共享下顶部和底部固定菜单的实现啊?
1 楼 zhuixinjian 2010-05-30  
什么叫巨型菜单....

相关推荐

    Android自定义ViewGroup实现带箭头的圆角矩形菜单

    本文和大家一起做一个带箭头的圆角矩形菜单,大概长下面这个样子:  要求顶上的箭头要对准菜单锚点,菜单项按压反色,菜单背景色和按压色可配置。 最简单的做法就是让UX给个三角形的图片往上一贴,但是转念一想...

    带箭头的圆角矩形菜单

    一个自定义ViewGroup,实现带箭头的圆角矩形菜单

    精通ANDROID 3(中文版)1/2

    7.1 Android菜单  7.1.1 创建菜单  7.1.2 使用菜单组  7.2 响应菜单项  7.3 创建测试工具来测试菜单  7.4 使用其他菜单类型  7.4.1 展开的菜单  7.4.2 使用图标菜单  7.4.3 使用子菜单  7.4.4 ...

    Android实现类似ios滑动按钮

    IOS的滑动按钮菜单在UI设计里面绝对堪称一绝,在学习了Android的自定义view后,我萌生了模仿它的想法。 实现上面的模拟需要自定义一个View; 1)、在View的OnDraw里画出圆角矩形,分别为灰色圆角矩形,红色圆角矩形...

    精通Android 3 (中文版)2/2

    7.1 Android菜单  7.1.1 创建菜单  7.1.2 使用菜单组  7.2 响应菜单项  7.3 创建测试工具来测试菜单  7.4 使用其他菜单类型  7.4.1 展开的菜单  7.4.2 使用图标菜单  7.4.3 使用子菜单  7.4.4 ...

    android开发实例大全_王东华

    实例033:使用ListActivity实现动态菜单 列表 71 实例034:加载手机磁盘中的文件 73 实例035:实现抽屉样式效果 76 实例036:在屏幕中动态显示多种对话框 82 实例037:手机秘书--重要事情提醒 88 实例038:动态添加...

    60个Android开发精典案例 Android软件源码.zip

    60个Android开发精典案例 Android软件源码: 2-1(Activity生命周期) 3-1(Button与点击监听器) 3-10-1(列表之ArrayAdapter适配) 3-10-2(列表之SimpleAdapter适配) 3-11(Dialog对话框) 3-12-5(Activity跳转与操作) 3-12...

    精通Android游戏开发

    71 4.2 了解在android中绘制多边形的问题 71 4.3 了解绘制矩形的问题 73 4.4 为asteroids创建一个polygon类 75 4.5 为asteroids创建polygonsprite类 80 4.6 游戏的体系结构 84 4.7 创建项目 84 4.7.1 创建游戏布局 ...

    android游戏开发从入门到应用实例

    3-9(Tab分页式菜单) 4-10(可视区域) 4-11-1(Animation动画) 4-11-2-1(动态位图) 4-11-2-2(帧动画) 4-11-2-3(剪切图动画) 4-13(操作游戏主角) 4-14-1(矩形碰撞) 4-14-2(圆形碰撞) 4-14-4(多矩形碰撞) 4-14-5(Region...

    Android仿今日头条顶部导航栏效果的实例代码

    当用户在ViewPager区域滑动页面时,对应的导航菜单标签也会相应的被选中,选中的标签通过一个矩形红框高亮显示,红框背景中的标签文字变为白色,红框外的区域标签文字仍为灰色。当用户直接在导航菜单选中某个标签时...

    gimp-android:用于 Android 密度和 9-patch 独立性的 GIMP 插件

    适用于 Android 的 GIMP 插件通过为大多数应用程序充分处理缩放问题来帮助实现标准和 9 块像素密度分辨率独立性。9-Patch 图像的注释9-patch 是一种巧妙的方法,可以使用 1 像素宽的透明边框标记普通 PNG 的弹性和...

    仿微信的图片选择加载源码 ImitationWeChatImageSelection.rar

    1、完全仿微信的图片选择,并且提供了多种图片加载接口,选择图片后可以旋转,可以裁剪成矩形或圆形,可以配置各种其他的参数 二、菜单功能 1、简述: 本项目是基于ImagePicker完善及界面修改。 主要工作: 原...

    UnityPhotosphericView:使用倒法线球的等矩形光球视图

    生成具有自定义半径(例如20)的程序球体(法向倒置)(菜单&gt; GameObject&gt;插入其他&gt;倒置球...) 使用equirectangular.shader作为球体的材质 基本源文件 笔记 最初想法的问题是,与常规的不亮着色器相比,纹理存在很...

    MatrixGame:基于矩形板开发游戏的环境-开源

    MatrixGame是一种开发工具,旨在快速生产基于矩形板的视频游戏。 必须将新游戏描述为新的Java类,该类扩展了允许使用交互式环境的Game类。 对于某些示例,请在下载后运行jar文件。 将打开一个小菜单,您可以运行所有...

    uva-androidgame:Native App Studio UvA 的自定义项目

    这里有一个开始游戏的按钮,一个查看高分的按钮,以及一个在必要时更改设置的按钮。 高分将存储在 SQL 数据库中,因此将使用 API。 ##Game 这是游戏屏幕的模型,其中您的角色是左下角的灰色矩形。 因此,您可以...

    ModernArtUI:安卓应用

    彩色矩形 搜索栏 选项菜单 对话 构建和测试 该项目是使用 Android Studio 构建的。 应用程序已使用位于app/libs Robotium 进行测试。 测试用例在具有 API 级别 22 的 Galaxy Nexus S AVD 模拟器上运行。 演示 截图...

Global site tag (gtag.js) - Google Analytics