- 浏览: 262337 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
zhanght327:
现在这个办法不好使了。。。火狐 谷歌 IE 360 迅雷 都不 ...
Aptana插件版Zip包下载方法 -
admins:
一般重启eclipse 与虚拟机就好了。或者看看logcat设 ...
Logcat问题的解决方法 -
CoolYJCK:
这个zip包用不了~~
Aptana插件版Zip包下载方法 -
crazysumer:
嗯,没有prepare报错了
Android的MediaPlayer错误 -
extjavaee:
问题就在于在layout中的决定ListView或 ...
ListView与Adapter使用要点
LayoutParams
java.lang.Object
<-- android.view.ViewGroup.LayoutParams
android:layout_height
Specifies the basic height of the view.
android:layout_width
Specifies the basic width of the view.
MarginLayoutParams
java.lang.Object
<-- android.view.ViewGroup.LayoutParams
<-- android.view.ViewGroup.MarginLayoutParams
android:layout_marginBottom
Specifies extra space on the bottom side of this view.
android:layout_marginLeft
Specifies extra space on the left side of this view.
android:layout_marginRight
Specifies extra space on the right side of this view.
android:layout_marginTop
Specifies extra space on the top side of this view.
FrameLayout
java.lang.Object
<-- android.view.ViewGroup.LayoutParams
<-- android.view.ViewGroup.MarginLayoutParams
<-- android.widget.FrameLayout.LayoutParams
android:layout_gravity
Standard gravity constant that a child can supply to its parent
注意区别android:gravity, 这个属性是android.view.Gravity,
FrameLayout.LayoutParams, LinearLayout.LayoutParams和各种常见的View都有 android:gravity ;注意RelativeLayout.LayoutParams没有这个属性。
LinearLayout
java.lang.Object
<-- android.view.ViewGroup.LayoutParams
<-- android.view.ViewGroup.MarginLayoutParams
<-- android.widget.LinearLayout.LayoutParams
android:layout_gravity
Standard gravity constant that a child can supply to its parent
android:layout_weight
RelativeLayout
java.lang.Object
<-- android.view.ViewGroup.LayoutParams
<-- android.view.ViewGroup.MarginLayoutParams
<-- android.widget.RelativeLayout.LayoutParams
android:layout_above
Positions the bottom edge of this view above the given anchor view ID.
android:layout_alignBaseline
Positions the baseline of this view on the baseline of the given anchor view ID.
android:layout_alignBottom
Makes the bottom edge of this view match the bottom edge of the given anchor view ID.
android:layout_alignLeft
Makes the left edge of this view match the left edge of the given anchor view ID.
android:layout_alignParentBottom
If true, makes the bottom edge of this view match the bottom edge of the parent.
android:layout_alignParentLeft
If true, makes the left edge of this view match the left edge of the parent.
android:layout_alignParentRight
If true, makes the right edge of this view match the right edge of the parent.
android:layout_alignParentTop
If true, makes the top edge of this view match the top edge of the parent.
android:layout_alignRight
Makes the right edge of this view match the right edge of the given anchor view ID.
android:layout_alignTop
Makes the top edge of this view match the top edge of the given anchor view ID.
android:layout_alignWithParentIfMissing
If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc.
android:layout_below
Positions the top edge of this view below the given anchor view ID.
android:layout_centerHorizontal
If true, centers this child horizontally within its parent.
android:layout_centerInParent
If true, centers this child horizontally and vertically within its parent.
android:layout_centerVertical
If true, centers this child vertically within its parent.
android:layout_toLeftOf
Positions the right edge of this view to the left of the given anchor view ID.
android:layout_toRightOf
Positions the left edge of this view to the right of the given anchor view ID.
TableLayout
java.lang.Object
<-- android.view.ViewGroup.LayoutParams
<-- android.view.ViewGroup.MarginLayoutParams
<-- android.widget.LinearLayout.LayoutParams
<-- android.widget.TableLayout.LayoutParams
AbsoluteLayout
java.lang.Object
<-- android.view.ViewGroup.LayoutParams
<-- android.widget.AbsoluteLayout.LayoutParams
java.lang.Object
<-- android.R.styleable
<-- public static final int[] AbsoluteLayout_Layout
android:layout_x
android:layout_y
Note: AbsoluteLayout is deprecated. Use other layouts instead.
总结
1. 界面的原点(0, 0)是除去status bar和title bar之后剩下的区域。 如果使用了全屏,不显示状态栏,不显示标题栏这样的主题后,区域的原点位置会相应改变。
2. FrameLayout的widget中使用类似android:layout_marginLeft="65px"这样的属性,一定要加上android:layout_gravity,否则margin无效。还要注意FrameLayout的android:layout_width和android:layout_height对layout_gravity的影响。
3. 使用布局属性一定要分清谁是parent,parent用的是什么layout,layout_width和layout_height的值。
4. 不同的布局属性也可以实现相同的功能。例如layout_gravity="center"和android:layout_centerInParent ="true"。
5. Eclipse的Android开发工具插件ADT里面有一个所见即所得的开发UI的功能。利用Graphical Layout可以预览的效果。但是,有时会遇到以下问题:
error!
UnsupportedOperationException: null
一般来说,这是因为所选择的Android版本不支持布局设置或者Android SDK不能很好的支持该layout的显示。可以尝试换其他Android版本或者看看该版本的SDK有没有更新。
发表评论
-
电脑能上网,Android模拟器不能上网的问题
2013-04-23 10:34 7037电脑能上网,Android模拟器不能上网 一 ... -
Android SDK相关问题
2012-11-15 10:57 20791. Android SDK Manager 卡在Fet ... -
Android环境
2012-07-02 10:16 802developer : developer.android.c ... -
xxx is not translated in yyy, zzz 的解决方法
2012-05-12 19:52 29449在Android SDK Tool r19之后, Export ... -
Android MAT
2012-03-01 11:23 3261安装MAT 生成hprof文件: DDMS-D ... -
分辨率不同的兼容要点
2011-11-15 12:55 0分辨率不同的兼容要点1. 换算比率l : m : h = 0. ... -
Android模拟器快捷键
2011-11-15 00:19 1037F1/PgUp Menu key 菜单键 ... -
Android中shared_prefs文件夹位置
2011-11-13 19:01 14976Android中shared_prefs文件夹位置 一 ... -
Android Device中添加busybox
2011-11-10 23:28 7483Android自带的toolbox(位于/system/bin ... -
Android adb shell
2011-11-04 23:28 11021、获取模拟器/设备列表 adb devices 2 ... -
Android SurfaceView
2011-10-31 12:01 1772最近自己做了个指南针应用,用到了SurfaceView。总结下 ... -
Logcat问题的解决方法
2011-09-28 09:40 5330Logcat在Android开发中是相当有用的。 但是,Lo ... -
Android中的数据存储与传输
2011-09-27 11:16 1095以下是工作中的开发总结,如有不妥,望请指出,谢谢! A ... -
ListView与Adapter使用要点
2011-08-12 14:44 14425项目用到ListView,由于要用到 ImageView ... -
Android的MediaPlayer错误
2011-07-22 12:43 24085在使用MediaPlayer的时候,要注意几个Listener ... -
Activity的setContentView与findViewById
2011-07-08 09:54 38451. Activity.setContentView(int ... -
Android的SeekBar
2011-07-07 14:52 37235使用SeekBar的时候,经常遇到的问题有如下: 1. se ... -
Android要点
2011-05-23 22:48 0控制层 Activity Intent and Inten ... -
Android Layout 相关
2011-05-23 11:38 9701 假如在同一个layout文件中有2个或以上的view使用相 ... -
Android界面元素
2011-05-17 11:15 8471 界面元素的层次 View与GroupView View ...
相关推荐
LayoutParams类描述
1.LinearLayout.LayoutParams使用说明 2.在Java代码中利用LinearLayout.LayoutParams构建布局
在此文档中列出了 所有WindowManager.LayoutParams的参数及详细信息
LayoutParams
各参数内容描述~~
WindowManager属性详解:WindowManager.LayoutParams 是 WindowManager 接口的嵌套类;继承于 ViewGroup.LayoutParams 。 它的内容十分丰富。其实WindowManager.java的主要内容就是由这个类定义构成。
自定义自动换行LinearLayout LayoutParams使用android.widget.LinearLayout.LayoutParams
LinearLayout.LayoutParams pm = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, 300); zxView = new ZXView(this, xlist, ylist, params); zxView.setLayoutParams(pm); layout.addView...
ViewGroup是布局管理器(layout)及view容器的基类。ViewGroup中,还定义了一个嵌套类ViewGroup.LayoutParams。这个类定义了一个显示对象的位置、大小等属性,view通过LayoutParams中的这些属性值来告之父级,它们将...
现需要交换两个控件...1、使用LayoutParams改变两个layout的属性,即其相对关系(below等),实现位置的交换,但是并没有交换的动画效果,是“瞬间”交换。 2、使用animation交换控件位置,实现了我需要的动画效果。
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT); layout.addView(mAdView, params); // ...
RelativeLayout.LayoutParams layout_params = null; layout_params = new RelativeLayout.LayoutParams(width, height); // padding是控件的内容相对控件的边缘的边距. // margin是控件边缘相对父控件,或者其他...
View lay = LayoutInflater.from(this).inflate(R.layout.mylinearlayout, null);// 讲xml问价解析为视图对象 merchant = (TextView) lay.findViewById(R.id.merchant); number = (TextView) lay....
View view = getLayoutInflater().inflate(R.layout.photo_choose_dialog, null); Dialog dialog = new Dialog(this, R.style.transparentFrameWindowStyle); dialog.setContentView(view, new LayoutParams...
import android.view.ViewGroup.LayoutParams; import android.view.animation.LinearInterpolator; import android.view.animation.TranslateAnimation; import android.widget.HorizontalScrollView; import ...
FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) view.getLayoutParams(); lp.order = -1; lp.flexGrow = 2; view.setLayoutParams(lp);屏幕截图: 标签:谷歌 google 排版库
自定义view的六种移动方式,通过使用offsetLeftAndRight(offsetX),setLayoutParams(layoutParams)等等,还可以控制view的滚动速度
setContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ImageView img = new ImageView(getApplication()); img.setImageResource(R.drawable.ic_launcher); ...
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); addView(containerLayout, layoutParams);...
然而这时候你一定要注意强制类型转换时的LayoutParams类型,因为android中存在3种LayoutParams,即RelativeLayout.LayoutParams、LinearLayout.LayoutParams、ViewGroup.LayoutParams,那么我们改用哪一个呢?...