postInvalidate();                            界面刷新

一个list元素可能默认为48px
android:visibility="invisible">                  设置组件显示visible 不显示invisible 消失gone
android:background="@null"                       设置组件无背景
android:layout_gravity="right|center_vertical"   向右并垂直居中
  <Button
   
     android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawableTop="@drawable/star"         将图片设置在按钮的上方
    android:text="按钮1"                            
    />
      
 
  <include
            android:id="@+id/vip_include_top"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            layout="@layout/top_1" />                  包含一个layout
 <SlidingDrawer
android:id="@+id/sliding"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:content="@+id/allApps"
android:handle="@+id/imageViewIcon" a
ndroid:orientation="vertical"
>                                                抽屉式设计必须设置content(类容控件)    handle(把手类容控件)
android:layout_alignParentBottom="true"          总是在父元素的底部
android:scrollbars="none"                        不要滚动条
android:gravity:       是对view控件本身来说的,是用来设置view本身的文本应该显示在view的什么位置,默认值是左侧

android:layout_gravity:是相对于包含改元素的父元素来说的,设置该元素在父元素的什么位置
<Button android:layout_width="120dip"
   android:layout_height="wrap_content"
   android:text="切换程序"
   style="@android:style/ButtonBar"  设置按钮为按钮条风格
   android:id="@+id/btn7"
   android:layout_weight="1" />

requestWindowFeature(Window.FEATURE_NO_TITLE);   设置无标题
在application 标签中添加android:theme=”@android:style/Theme.NoTitleBar” 去掉所有Activity界面的标题栏
修改AndroidManifest.xml
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);       设置全屏
<resources>
 <style name="tab_btn"> 
     <item name="android:textAppearance">@style/tab_item_text_style</item>  
     <item name="android:gravity">center_horizontal</item>
     <item name="android:background">@drawable/trans</item>
     <item name="android:layout_width">0.0dip</item> 
     <item name="android:layout_height">wrap_content</item> 
     <item name="android:button">@null</item> 
     <item name="android:layout_weight">1.0</item>   自定义按钮的Style属性
 </style>
</resources>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_enabled="false" android:drawable="@drawable/input_normal" />
  <item android:state_pressed="true" android:drawable="@drawable/input_normal" />
  <item android:state_focused="true" android:drawable="@drawable/input_over" />
  </selector>                                              定义组件得到焦点,点击,激活的状态

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">  
<gradient     
android:startColor="#FFFFFF"     
android:endColor="#000000"     
android:angle="270" />  </shape>                             设置Drawable渐变
setBackgroundResource(R.drawable.bg);                        调用

//设置 Gallery样式在BaseAdapter的getView中

TypedArray typedArray = context.obtainStyledAttributes(R.styleable.Gallery);
imageView.setBackgroundResource(typedArray.getResourceId(R.styleable.Gallery_android_galleryItemBackground, 0));
return imageView;
 android:spacing="10dp"  //Gallery间隔
 
第一类:属性值为true或false

android:layout_centerHrizontal? 水平居中
android:layout_centerVertical?? 垂直居中
android:layout_centerInparent???相对于父元素完全居中
android:layout_alignParentBottom 贴紧父元素的下边缘
android:layout_alignParentLeft?? 贴紧父元素的左边缘
android:layout_alignParentRight? 贴紧父元素的右边缘
android:layout_alignParentTop??? 贴紧父元素的上边缘
android:layout_alignWithParentIfMissing? 如果对应的兄弟元素找不到的话就以父元素做参照物
第二类:属性值必须为id的引用名”
android:layout_below????? 在某元素的下方
android:layout_above????? 在某元素的的上方
android:layout_toLeftOf?? 在某元素的左边
android:layout_toRightOf? 在某元素的右边
android:layout_alignTop?? 本元素的上边缘和某元素的的上边缘对齐
android:layout_alignLeft? 本元素的左边缘和某元素的的左边缘对齐
android:layout_alignBottom 本元素的下边缘和某元素的的下边缘对齐
android:layout_alignRight? 本元素的右边缘和某元素的的右边缘对齐
第三类:属性值为具体的像素值,如30dip,40px
android:layout_marginBottom?????? 离某元素底边缘的距离
android:layout_marginLeft???????? 离某元素左边缘的距离
android:layout_marginRight??????? 离某元素右边缘的距离
android:layout_marginTop????????? 离某元素上边缘的距离
 
android:scaleType:android:scaleType是控制图片如何resized/moved来匹对ImageView的size。
ImageView.ScaleType / android:scaleType值的意义区别:
CENTER /center? 按图片的原来size居中显示,当图片长/宽超过View的长/宽,则截取图片的居中部分显示
CENTER_CROP / centerCrop? 按比例扩大图片的size居中显示,使得图片长(宽)等于或大于View的长(宽)
CENTER_INSIDE / centerInside? 将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽
FIT_CENTER / fitCenter? 把图片按比例扩大/缩小到View的宽度,居中显示
FIT_END / fitEnd?? 把图片按比例扩大/缩小到View的宽度,显示在View的下部分位置
FIT_START / fitStart? 把图片按比例扩大/缩小到View的宽度,显示在View的上部分位置
FIT_XY / fitXY? 把图片不按比例扩大/缩小到View的大小显示MATRIX / matrix 用矩阵来绘制,动态缩小放大图片来显示。
** 要注意一点,Drawable文件夹里面的图片命名是不能大写的。

Android布局技巧的更多相关文章

  1. 个人技术博客(1/2)android布局技巧

    (1)weight属性的合理应用 当使用match_parent(fill_parent)时,需要经过计算,否则会出现如下情况 代码: <LinearLayout xmlns:android=& ...

  2. Android学习笔记之布局技巧以及布局中的细节介绍....

    PS:休息两天,放一放手上的东西,做做总结... 学习内容: 1.Android中LinearLayout布局技巧... 2.layout中drawable属性的区别...   先简单的介绍一下dra ...

  3. 移动平台3G手机网站前端开发布局技巧

    本文转载至:移动平台3G手机网站前端开发布局技巧汇总 - 前端开发-武方博 您或许正在或准备参与一个WepApp项目,您或许正在Google搜索mobile development相 关的文章,您或许 ...

  4. 移动平台3G手机网站前端开发布局技巧汇总

    移动平台3G手机网站前端开发布局技巧汇总 作者:前端开发-武方博   发布:2011-05-10 09:11   分类:移动开发   阅读:120,618 views   7条评论     您或许正在 ...

  5. Android开发技巧——大图裁剪

    本篇内容是接上篇<Android开发技巧--定制仿微信图片裁剪控件> 的,先简单介绍对上篇所封装的裁剪控件的使用,再详细说明如何使用它进行大图裁剪,包括对旋转图片的裁剪. 裁剪控件的简单使 ...

  6. Android开发技巧——使用PopupWindow实现弹出菜单

    在本文当中,我将会与大家分享一个封装了PopupWindow实现弹出菜单的类,并说明它的实现与使用. 因对界面的需求,android原生的弹出菜单已不能满足我们的需求,自定义菜单成了我们的唯一选择,在 ...

  7. Android开发技巧——实现可复用的ActionSheet菜单

    在上一篇<Android开发技巧--使用Dialog实现仿QQ的ActionSheet菜单>中,讲了这种菜单的实现过程,接下来将把它改成一个可复用的控件库. 本文原创,转载请注明出处: h ...

  8. Android开发技巧——自定义控件之使用style

    Android开发技巧--自定义控件之使用style 回顾 在上一篇<Android开发技巧--自定义控件之自定义属性>中,我讲到了如何定义属性以及在自定义控件中获取这些属性的值,也提到了 ...

  9. Android开发技巧——自定义控件之自定义属性

    Android开发技巧--自定义控件之自定义属性 掌握自定义控件是很重要的,因为通过自定义控件,能够:解决UI问题,优化布局性能,简化布局代码. 上一篇讲了如何通过xml把几个控件组织起来,并继承某个 ...

随机推荐

  1. Ehcache详细解读

    [http://raychase.iteye.com/blog/1545906]   Ehcache 是现在最流行的纯Java开源缓存框架. [通过编程方式使用EhCache ]   //从class ...

  2. jsp中使用动态数据进行mySQL数据库的两种操作方法

    使用动态数据进行数据库内容的增删改查操作有两种方法: 在此定义数据库连接为conn 假设有表单进行数据输入并提交到处理页面一种是使用预编译格式: 其格式如下: String name = reques ...

  3. Web网站压力测试工具

    使用Microsoft Web Application Stress Tool对web进行压力测试 不错关于压力测试博客: http://blog.sina.com.cn/s/blog_5155e8d ...

  4. How to Send Information (String, Image, Record) Between Two Applications

    http://delphi.about.com/od/windowsshellapi/a/wm_copydata.htm here are many situation when you need t ...

  5. CMSIS Example - osMutex osMutexWait osMutexRelease

    osMutexDef( Mutex ); osMutexId mutex; void Thread0( void * arg); void Thread1( void * arg); osThread ...

  6. hdu 5273 Dylans loves sequence 逆序数简单递推

    Dylans loves sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

  7. Linux文件时间属性

    Linux文件时间属性                                                                                         ...

  8. Linux中搭建SVNserver

    一 下载工具 1. subversion-1.6.17.tar.gz 2. subversion-deps-1.6.17.tar.gz 二 解压两个包: 1.在此之前,我已经创建了一个用户svnroo ...

  9. UESTC 890 Card Trick(DP 纸牌魔术)

    题意  给你一些牌  所有正面朝下放桌子上   你选一个起点    翻开那张牌   牌上的数字是几就向前走几步   J,Q,K 都是向前走10步  A向前走11步   知道向前走相应的步数后超过了终点 ...

  10. C语言中的函数

    C语言中的函数 目录 概述——对函数的理解 C语言中函数的定义和声明 函数允许的参数类型 函数允许的返回类型 递归 概述 由于有些代码段在编写程序的时候经常会用到,此时我们为了减少代码文件的长度和增加 ...