- 浏览: 100369 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
ndzj981479673:
TexShop编辑中文例子 -
shenchui:
谢谢分享辛苦咯
FlexBook的动态添加 -
benri1:
已经验证,可以使用
Flex HttpService中乱码的解决 -
无谓生活:
楼主你好,我用的这种方法,总报找不到文件错误,请问是怎么回事啊 ...
Dojo异步上传文件 -
琼露露:
楼主,/sdcard/windmill.obj这个文件给下行不 ...
Android导入3D场景
对于很多刚刚接触Android的人来说,界面布局应该是件比较头痛的事吧,xml下进行的布局确实有那么点繁琐,适应花了一段时间,最近写了个View的Layout,500多行,真是吐血,不过写完之后对Android界面布局有了蛮深刻的认识~~~
我用到的主要有三种布局方式:
1.Linearlayout:这个很常见,线性布局.大多数情况下将它的空间宽度或高度设置成fill_parent和wrap_content比较合适.最简单的情况,两个TextView,前面一个宽度未知,系统将根据前面TextView的实际宽度在其之后添加另一个TextView.
还有一点,这种布局下两个控件中间要想间隔一定距离的话,中间可以加上一个没有内容,只有宽度的TextView.
2.AbsoluteLayout:前一种情况下,两个控件之间需要一个TextView间隔,很多情况下不太方便,可能需要大量的TextView,就可以考虑使用AbsoluteLayout取而代之了,这种布局需要你给出确定的x,y,都是相对于parent的左上顶点坐标的,一般来说,用这种布局最好给出控件的确定宽度和高度.
3.FrameLayout:这个用的不是那么多,需要知道的就是这种布局下只能显示一个View控件,Layout好像是可以重叠显示的,并且总是在parent的左上角添加.
这三种布局最为常见,其余的看到的不多,RelativeLayout没有用过,也就不好多说,发下图吧,还有代码,不过代码确实比较复杂:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/shop_back"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="260px" android:orientation="horizontal"> <FrameLayout android:layout_width="400px" android:layout_height="fill_parent" android:background="@drawable/frame_border"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/shopinfo_back"> <TextView android:layout_width="fill_parent" android:layout_height="20px"> </TextView> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_x="125px" android:layout_y="10px" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:text="欢迎光临: "> </TextView> <TextView android:id="@+id/shopinfo_shopname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp"> </TextView> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_x="125px" android:layout_y="40px" android:orientation="horizontal"> <TextView android:layout_width="250px" android:layout_height="wrap_content" android:textSize="14sp" android:text="本店公告: 全场一律七折,机不可失,失不再来"> </TextView> </LinearLayout> <ScrollView android:layout_width="332px" android:layout_height="90px" android:layout_x="25px" android:layout_y="125px" android:scrollbars="vertical" android:fadingEdge="vertical"> <TextView android:id="@+id/shopinfo_content" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="12sp"> </TextView> </ScrollView> </AbsoluteLayout> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listview_layout" android:layout_width="160px" android:layout_height="250px" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="20px"> </TextView> <ImageView android:id="@+id/list_title_image" android:layout_width="fill_parent" android:layout_height="40px" android:background="@drawable/list_title"> </ImageView> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/name_price_title" android:layout_width="fill_parent" android:layout_height="210px"> <TextView android:layout_width="wrap_content" android:layout_height="30px" android:layout_x="20px" android:layout_y="0px" android:textSize="14sp" android:text="商品名称"> </TextView> <TextView android:layout_width="wrap_content" android:layout_height="30px" android:layout_x="110px" android:layout_y="0px" android:textSize="14sp" android:text="价格"> </TextView> <ListView android:id="@+id/product_list" android:layout_width="140px" android:layout_height="150px" android:layout_x="10px" android:layout_y="30px"> </ListView> </AbsoluteLayout> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/product_layout" android:layout_width="240px" android:layout_height="250px" android:orientation="vertical"> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/brief_layout" android:layout_width="fill_parent" android:layout_height="110px"> <Button android:id="@+id/page_later" android:layout_width="20px" android:layout_height="100px" android:layout_x="0px" android:layout_y="10px" android:background="@drawable/later_image"> </Button> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="100px" android:layout_height="76px" android:layout_x="20px" android:layout_y="22px" android:background="@drawable/image_border"> <ImageView android:id="@+id/image" android:layout_width="96px" android:layout_height="72px" android:layout_x="2px" android:layout_y="2px"> </ImageView> </AbsoluteLayout> <Button android:id="@+id/page_next" android:layout_width="20px" android:layout_height="100px" android:layout_x="120px" android:layout_y="10px" android:background="@drawable/next_image"> </Button> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/title_layout" android:layout_width="95px" android:layout_height="100px" android:layout_x="140px" android:layout_y="10px" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="10px" android:textSize="12sp"> </TextView> <TextView android:id="@+id/product_name_info" android:layout_width="fill_parent" android:layout_height="30px" android:textSize="12sp"> </TextView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10sp" android:text="价格:"> </TextView> <TextView android:id="@+id/product_price_info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10sp"> </TextView> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10sp" android:text="类型:"> </TextView> <TextView android:id="@+id/product_type_info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10sp"> </TextView> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10sp" android:text="特点:"> </TextView> <TextView android:id="@+id/product_feature_info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10sp" android:text="时尚简约,功能齐全"> </TextView> </LinearLayout> </LinearLayout> </AbsoluteLayout> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/button_layout" android:layout_width="fill_parent" android:layout_height="140px"> <TextView android:layout_width="fill_parent" android:layout_height="20px" android:layout_x="20px" android:layout_y="0px" android:textSize="12sp" android:text="详细信息:"> </TextView> <ScrollView android:layout_width="200px" android:layout_height="80px" android:layout_x="20px" android:layout_y="20px" android:scrollbars="vertical" android:fadingEdge="vertical"> <TextView android:id="@+id/productContent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="12sp"> </TextView> </ScrollView> <LinearLayout android:layout_width="90px" android:layout_height="30px" android:layout_x="20px" android:layout_y="110px" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="13sp" android:text="我要买: "> </TextView> <EditText android:id="@+id/buy_number" android:layout_width="30px" android:layout_height="30px" android:textSize="9sp" android:text="1"> </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="13sp" android:text="件"> </TextView> </LinearLayout> <Button android:id="@+id/button_addshoppingcart" android:layout_width="80px" android:layout_height="20px" android:layout_x="130px" android:layout_y="112px" android:background="@drawable/button_addshoppingcart"> </Button> </AbsoluteLayout> </LinearLayout> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <TextView android:layout_width="30px" android:layout_height="fill_parent"> </TextView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="30px"> </TextView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="30px" android:orientation="horizontal"> <TextView android:layout_height="wrap_content" android:layout_width="5px" > </TextView> <TextView android:layout_height="wrap_content" android:layout_width="95px" android:textSize="16sp" android:text="商品名称"> </TextView> <TextView android:layout_height="wrap_content" android:layout_width="60px" android:textSize="16sp" android:text="单价"> </TextView> <TextView android:layout_height="wrap_content" android:layout_width="60px" android:textSize="16sp" android:text="数量"> </TextView> <TextView android:layout_height="wrap_content" android:layout_width="60px" android:textSize="16sp" android:text="合计"> </TextView> </LinearLayout> <ListView android:id="@+id/shoppingcart_list" android:layout_width="340px" android:layout_height="150px"> </ListView> <TextView android:layout_height="10px" android:layout_width="fill_parent"> </TextView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <TextView android:layout_width="140px" android:layout_height="fill_parent"> </TextView> <Button android:id="@+id/button_buy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_buyproduct"> </Button> </LinearLayout> </LinearLayout> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <TextView android:layout_width="30px" android:layout_height="fill_parent"> </TextView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="30px"> </TextView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="50px" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:textSize="16sp" android:text="此次交易总额:"> </TextView> <TextView android:id="@+id/totalpay" android:layout_width="wrap_content" android:layout_height="fill_parent" android:textSize="16sp"> </TextView> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:textSize="16sp" android:text=" ,请填写您的订单."> </TextView> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="40px" android:orientation="horizontal"> <TextView android:layout_width="100px" android:layout_height="fill_parent" android:textSize="16sp" android:text="详细地址:"> </TextView> <EditText android:id="@+id/user_address" android:layout_width="220px" android:layout_height="32px" android:textSize="10sp"> </EditText> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="40px" android:orientation="horizontal"> <TextView android:layout_width="100px" android:layout_height="fill_parent" android:textSize="16sp" android:text="邮政编码:"> </TextView> <EditText android:id="@+id/user_zipcode" android:layout_width="220px" android:layout_height="32px" android:textSize="10sp"> </EditText> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="40px" android:orientation="horizontal"> <TextView android:layout_width="100px" android:layout_height="fill_parent" android:textSize="16sp" android:text="联系号码:"> </TextView> <EditText android:id="@+id/user_phone" android:layout_width="220px" android:layout_height="32px" android:textSize="10sp"> </EditText> </LinearLayout> <AbsoluteLayout android:layout_width="fill_parent" android:layout_height="50px"> <Button android:id="@+id/button_pay" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="60px" android:layout_y="10px" android:background="@drawable/button_pay"> </Button> <Button android:id="@+id/button_cancelbuy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="210px" android:layout_y="10px" android:background="@drawable/button_cancelbuy"> </Button> </AbsoluteLayout> </LinearLayout> </LinearLayout> </FrameLayout> <AbsoluteLayout android:layout_width="wrap_content" android:layout_height="fill_parent"> <Button android:id="@+id/button_shopinfo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="0px" android:layout_y="30px" android:background="@drawable/button_shopinfo"> </Button> <Button android:id="@+id/button_productlist" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="0px" android:layout_y="80px" android:background="@drawable/button_productlist"> </Button> <Button android:id="@+id/button_shoppingcart" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="0px" android:layout_y="130px" android:background="@drawable/button_shoppingcart"> </Button> </AbsoluteLayout> </LinearLayout></LinearLayout>
评论
2 楼
pahu2000
2011-04-26
gmxstar 写道
代码呢?。。。。
代码指的是xml配置文件,android的界面布局
1 楼
gmxstar
2011-04-14
代码呢?。。。。
发表评论
-
Android导入项目中遇到的一些问题及解决方法
2011-01-26 23:12 2287之前的半年都在昏天黑地准备考研,一直都没时间 ... -
SurfaceView如何结合Android UI
2010-07-06 22:25 6919SurfaceView提供的是直接访问画布进行绘图的机制,在里 ... -
Android用户登录
2010-04-05 18:28 8595前几天和教我们计算机网络的老师讨论了一些关于手机应用发展前景的 ... -
Android导入3D场景
2010-03-29 16:20 12457Android上的3D目前还是很少有人涉足的领域,虽然感觉效率 ... -
关于Android纹理映射
2010-03-23 21:39 2401首先发泄一下不满,Androi ...
相关推荐
android界面布局详解
android界面布局,介绍android界面的各个布局样式
有关于android界面布局的详解,对初学者应该很有帮助
android界面布局设计
可以参考对应的文章有描述。 地址:http://blog.csdn.net/gufengcangying/article/details/24883831
android界面布局相关教程以及工具,自动转换
设计android界面布局实用教案.pptx
设计android界面布局学习教案.pptx
设计android界面布局PPT学习教案.pptx
Android 开发在每个布局中加上水印效果。需求:在每个布局中加上水印效果
android线性、相对、表格、绝对、标签、层布局描述,使用桌面组件Widget布局,在屏幕上实现文字显示,设置字体,下拉列表,自动实现输入文本等功能。经过调试。
android 开发入门很好的实例,我就是按照这个步骤进行的开发。
GUI可视化设计器——DroidDraw Dr oidDraw是基于Java Swing的Android界面设计器,可以通过它生成复杂的Android Layout Xml文件。
最新最实用的android菜单界面布局,不下会后悔的
Android界面布局的目的是为了合理利用屏幕空间,并能适配多种屏幕。我们可以利用布局来设计各个控件的位置排布。 Android提供了6种基本布局类:帧布局(FrameLayout)、线性布局(LinearLayout)、绝对布局...
安卓Android源码——UI界面源码.zip