Android View

LinearLayout ,RelativeLayout 等是ViewGroup的子类。

每个ViewGrop的子类都有自己的ViewGroup.LayoutParams,用来排列其孩子。

LayoutParams android.view.View.getLayoutParams()

public ViewGroup.LayoutParams getLayoutParams ()

Added in API level 1
Get the LayoutParams associated with this view. All views should have layout parameters. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children. This method may return null if this View is not attached to a parent ViewGroup or setLayoutParams(android.view.ViewGroup.LayoutParams) was not invoked successfully. When a View is attached to a parent ViewGroup, this method must not return null.
Returns

The LayoutParams associated with this view, or null if no parameters have been set yet 

获取这个view的布局变量。所有view都会有布局变量。这些变量要提供给这个view的父亲,父亲用这些变量来布局这个view。有许多 ViewGroup.LayoutParams的子类,ViewGroup的子类布局他们的孩子时会用到他们。如果一个view没有添加到一个父ViewGroup里或者setLayoutParams方法没有被成功调用的话,这个方法会返回null。否则一定不会返回null。


view.invalidate() :如果view是visible的,则在将来某一点执行onDraw()方法,如果在子线程中让view执行onDraw(),则调用view.postInvalidate()。


listView.addHeaderView(v, data, isSelectable);

listView.addFooterView(v, data, isSelectable);


ListView 是 AdapterView的子类,adapterView.getFirstVisiblePosition():

Returns the position within the adapter's data set for the first item displayed on screen.




你可能感兴趣的:(Android View)