0
此處描述的問題在3.0以及3.035上遇到3.1宏碁Iconia A500遇到。以下佈局用於片段(不是 ListFragment)。不知它導致一個ListView,加入到 fragment_swipeview_lr_leftview_body(分別 fragment_swipeview_lr_rightview_body),待一遍一遍測量 ,從而刷新其內容更頻繁然後 需要並因此顯著減緩裝置。ListView測量導致不斷的getView(..)請求,減慢設備
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_swipeview_lr_mainlayout" android:layout_height="fill_parent" android:layout_width="fill_parent">
<RelativeLayout android:id="@+id/fragment_swipeview_lr_leftview"
android:layout_height="fill_parent" android:layout_width="wrap_content"
android:layout_marginRight="5dip">
<RelativeLayout android:layout_height="wrap_content"
android:id="@+id/fragment_swipeview_lr_leftview_header"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:background="@drawable/fragment_swipeview_header_background_left"
android:layout_width="wrap_content" android:layout_alignLeft="@+id/fragment_swipeview_lr_leftview_body"
android:layout_alignRight="@+id/fragment_swipeview_lr_leftview_body">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/fragment_swipeview_vt_leftview_headertext"
android:text="Left Heading" android:textAppearance="@style/style_text_swipeview_header"
android:layout_marginLeft="10dip"></TextView>
</RelativeLayout>
<RelativeLayout android:background="@drawable/fragment_swipeview_body_background_left"
android:layout_height="fill_parent" android:layout_below="@id/fragment_swipeview_lr_leftview_header"
android:layout_width="wrap_content" android:id="@+id/fragment_swipeview_lr_leftview_body"></RelativeLayout>
</RelativeLayout>
<RelativeLayout android:layout_height="fill_parent"
android:layout_toRightOf="@+id/fragment_swipeview_lr_leftview"
android:layout_width="wrap_content" android:id="@+id/fragment_swipeview_lr_rightview">
<RelativeLayout android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/fragment_swipeview_lr_header_body_wrapper"
android:layout_toRightOf="@+id/fragment_swipeview_vi_rightview_shadow">
<RelativeLayout android:layout_alignLeft="@+id/fragment_swipeview_lr_rightview_body"
android:layout_alignRight="@+id/fragment_swipeview_lr_rightview_body"
android:layout_height="wrap_content" android:layout_centerHorizontal="true"
android:layout_width="wrap_content" android:layout_alignParentTop="true"
android:id="@+id/fragment_swipeview_lr_rightview_header"
android:background="@drawable/fragment_swipeview_header_background_right">
<TextView android:text="Right Heading" android:layout_height="wrap_content"
android:layout_marginLeft="10dip" android:textAppearance="@style/style_text_swipeview_header"
android:layout_width="wrap_content" android:id="@+id/fragment_swipeview_vt_rightview_headertext"></TextView>
</RelativeLayout>
<RelativeLayout android:layout_height="fill_parent"
android:layout_width="wrap_content" android:layout_below="@+id/fragment_swipeview_lr_rightview_header"
android:id="@+id/fragment_swipeview_lr_rightview_body"
android:background="@drawable/fragment_swipeview_body_background_right"></RelativeLayout>
</RelativeLayout>
<ImageView android:background="@drawable/general_shadow_left"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:id="@+id/fragment_swipeview_vi_rightview_shadow"
android:visibility="gone"></ImageView>
</RelativeLayout>
</RelativeLayout>
的ListView中使用以下代碼(使用顯式 LayoutParameters以及試過)加入。
public void addViewToLeftContentLayout(View v) {
leftContent.addView(v); // leftcontent == fragment_swipeview_lr_leftview_body
fragment_swipeview_lr_leftview_body
}
這裏是表示各個測量更新棧跟蹤:
AdapterIngredientList.getView(int, View, ViewGroup) line: 43
ListView(AbsListView).obtainView(int, boolean[]) line: 1970
ListView.measureHeightOfChildren(int, int, int, int, int) line: 1228
ListView.onMeasure(int, int) line: 1139
ListView(View).measure(int, int) line: 10828
RelativeLayout.measureChild(View, RelativeLayout$LayoutParams, int,
int) line: 566
RelativeLayout.onMeasure(int, int) line: 381
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
RelativeLayout.measureChildHorizontal(View, RelativeLayout
$LayoutParams, int, int) line: 581
RelativeLayout.onMeasure(int, int) line: 365
RelativeLayout(View).measure(int, int) line: 10828
LinearLayout(ViewGroup).measureChildWithMargins(View, int, int, int,
int) line: 4351
LinearLayout.measureChildBeforeLayout(View, int, int, int, int, int)
line: 1284
LinearLayout.measureVertical(int, int) line: 613
LinearLayout.onMeasure(int, int) line: 519
LinearLayout(View).measure(int, int) line: 10828
FrameLayout(ViewGroup).measureChildWithMargins(View, int, int, int,
int) line: 4351
FrameLayout.onMeasure(int, int) line: 267
FrameLayout(View).measure(int, int) line: 10828
LinearLayout.measureVertical(int, int) line: 764
LinearLayout.onMeasure(int, int) line: 519
LinearLayout(View).measure(int, int) line: 10828
PhoneWindow$DecorView(ViewGroup).measureChildWithMargins(View, int,
int, int, int) line: 4351
PhoneWindow$DecorView(FrameLayout).onMeasure(int, int) line: 267
PhoneWindow$DecorView.onMeasure(int, int) line: 1908
PhoneWindow$DecorView(View).measure(int, int) line: 10828
ViewRoot.performTraversals() line: 909
ViewRoot.handleMessage(Message) line: 2003
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 132
ActivityThread.main(String[]) line: 4026
Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 491
ZygoteInit$MethodAndArgsCaller.run() line: 841
ZygoteInit.main(String[]) line: 599
NativeStart.main(String[]) line: not available [native method]
任何建議/變通辦法,將不勝感激。 關於帕特里克
不幸的是,將wrap_content更改爲fill_parent不是一個選項。我只是簡化了佈局,現在就開始工作。非常感謝 –