- android
- android.accessibilityservice
- android.accounts
- android.content
- android.database.sqlite
- android.graphics
- android.location
- android.media
- android.net
- android.os
- android.text
- android.view
- android.view.inputmethod
- android.widget
- AbsListView
- AbsoluteLayout
- AbsSeekBar
- AbsSpinner
- AdapterView
- AnalogClock
- BaseAdapter
- BaseExpandableListAdapter
- Button
- CheckBox
- CheckedTextView
- Checkable
- Chronometer
- CompoundButton
- CursorAdapter
- CursorTreeAdapter
- DatePicker
- DialerFilter
- DigitalClock
- EditText
- Filter
- Filter.FilterListener
- Filter.FilterResults
- ExpandableListAdapter
- Filterable
- Gallery
- Gallery.LayoutParams
- GridView
- GridLayout
- RadioGroup
- ImageView
- HorizontalScrollView
- ImageButton
- ImageSwitcher
- FilterQueryProvider
- ListAdapter
- ListView
- MediaController
- QuickContactBadge
- RadioButton
- RatingBar
- RelativeLayout
- RemoteViews
- ResourceCursorAdapter
- ResourceCursorTreeAdapter
- Scroller
- ScrollView
- SearchView
- SeekBar
- SeekBar.OnSeekBarChangeListener
- SimpleAdapter
- SimpleCursorAdapter
- SimpleCursorTreeAdapter
- SimpleExpandableListAdapter
- SlidingDrawer
- Spinner
- SpinnerAdapter
- WrapperListAdapter
- TabHost
- TabHost.TabSpec
- TextView
- TimePicker
- Toast
- TableLayout
- TableRow
- TableRow.LayoutParams
- TabWidget
- TextSwitcher
- ToggleButton
- TwoLineListItem
- VideoView
- ViewAnimator
- ViewFlipper
- ViewSwitcher
- ZoomButtonsController
- ZoomButton
- ZoomControls
- dalvik.system
AbsoluteLayout
AbsoluteLayout
版本:Android 2.2 r1
public class AbsoluteLayout extends ViewGroup
java.lang.Object
android.view.ViewGroup
android.widget.AbsoluteLayout
直接子类
WebView
此类不赞成使用。
推荐使用 FrameLayout
, RelativeLayout
或者定制的 layout 代替。
概述
让你指定子元素的 xy 精确坐标的布局。绝对布局缺乏灵活性,在没有绝对定位的情况下相比其他类型的布局更难维护。
公共方法
public ViewGroup.LayoutParams generateLayoutParams (AttributeSet attrs)
返回一组新的基于所支持的属性集的布局参数
参数
attrs 构建 layout 布局参数的属性集合
返回值
一个 ViewGroup.LayoutParams 的实例或者它的一个子类
受保护方法
protected ViewGroup.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)
返回一组合法的受支持的布局参数。当一个 ViewGroup 传递一个布局参数没有通过 checkLayoutParams(android.view.ViewGroup.LayoutParams) 检测的视图时,此方法被调用。此方法会返回一组新的适合当前 ViewGroup 的布局参数,可能从指定的一组布局参数中复制适当的属性。
参数
p 被转换成一组适合当前 ViewGroup 的布局参数
返回值
an instance of ViewGroup.LayoutParams or one of its descendants
一个 ViewGroup.LayoutParams 的实例或者其中的一个子节点
protected boolean checkLayoutParams (ViewGroup.LayoutParams p)
(译者注:检测是不是 AbsoluteLayout.LayoutParams 的实例,见源码:
protected ViewGroup.LayoutParams generateDefaultLayoutParams ()
返回一组宽度为 WRAP_CONTENT,高度为 WRAP_CONTENT,坐标是(0,0)的布局参数
返回值
一组默认的布局参数或 null 值
protected void onLayout (boolean changed, int l, int t, int r, int b)
在此视图 view 给他的每一个子元素分配大小和位置时调用。 派生类可以重写此方法并且重新安排他们子类的布局。
参数
changed 这是当前视图 view 的一个新的大小或位置
l 相对于父节点的左边位置
t 相对于父节点的顶点位置
r 相对于父节点的右边位置
b 相对于父节点的底部位置
protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)
测量视图以确定其内容宽度和高度。此方法被 measure(int, int) 调用。需要被子类重写以提供对其内容准确高效的测量。
约定:当重写此方法时,你必须调用 setMeasuredDimension(int, int) 来保存当前视图 view 的宽度和高度。不成功调用此方法将会导致一个 IllegalStateException 异常,是由 measure(int, int) 抛出。所以调用父类的 onMeasure(int, int) 方法是必须的。
父类的实现是以背景大小为默认大小,除非 MeasureSpec(测量细则)允许更大的背景。子类可以重写 onMeasure(int,int) 以对其内容提供更佳的尺寸。
如果此方法被重写,那么子类的责任是确认测量高度和测量宽度要大于视图 view 的最小宽度和最小高度(getSuggestedMinimumHeight() and getSuggestedMinimumWidth()),使用这两个方法可以取得最小宽度和最小高度。
参数
widthMeasureSpec 强加于父节点的横向空间要求。要求是使用 View.MeasureSpec 进行编码
heightMeasureSpec 强加于父节点的纵向空间要求。要求是使用 View.MeasureSpec 进行编码。
补充
文件链接
如何动态改变 AbsoluteLayout 布局中其它布局的坐标
示例代码
<AbsoluteLayout
android:id="@+id/AbsoluteLayout01" android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<TextView
android:text="TextView01" android:id="@+id/TextView01"
android:layout_height="wrap_content" android:layout_y="10px"
android:layout_width="wrap_content" android:layout_x="110px">
</TextView>
</AbsoluteLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论