2010-12-30 7 views
0

저는 현재 4 개의 탭이있는 레이아웃을 가지고 있습니다. 첫 번째 탭에는 앱의 홈 화면이 있고 다른 활동 아이콘에는 4 개의 이미지 뷰가로드됩니다. 두 번째 탭은 세 번째 탭과 마찬가지로 webview (매우 기본적인 탭)를로드합니다. 마지막 탭은지도를로드합니다. 앱이 매우 느리게로드되고 약 11 초가 걸리며 Eclipse에서 디버깅 할 때 거의 모든 시간이 setContentView에 소요되지만 내 레이아웃에서로드하는 데 너무 오래 걸리는 부분을 파악할 수 없습니다.레이아웃로드 시간을보다 효율적으로 만들려면 어떻게해야합니까?

<?xml version="1.0" encoding="utf-8"?> 

<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tabhost" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      > 
      <RelativeLayout 
       android:id="@+id/tab1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/background" 
       > 
       <ImageView 
        android:id="@+id/HomeButtonEvents" 
        android:src="@drawable/eventsicon" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:paddingBottom="95dp" 
        android:clickable="true" 
        /> 
       <ImageView 
        android:id="@+id/CancelledClasses" 
        android:src="@drawable/cancelledicon" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentRight="true" 
        /> 
       <ImageView 
        android:id="@+id/CourseSchedule" 
        android:src="@drawable/coursesicon" 
        android:layout_width="141dp" 
        android:layout_height="139dp" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        /> 
       <ImageView 
        android:id="@+id/POTD" 
        android:src="@drawable/potdicon" 
        android:layout_width="294dp" 
        android:layout_height="247dp" 
        android:paddingTop="45dp" 
        android:paddingRight="1dp" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentRight="true" 
        android:layout_toRightOf="@id/CourseSchedule" 
        /> 
<!--   <ImageView --> 
<!--    android:id="@+id/potdview"--> 
<!--    android:layout_width="wrap_content"--> 
<!--    android:layout_height="wrap_content"--> 
<!--    android:paddingTop="0dp" --> 
<!--    android:paddingRight="1dp"--> 
<!--    android:paddingBottom="150dp" --> 
<!--    android:layout_alignParentTop="true"--> 
<!--    android:layout_alignParentRight="true" --> 
<!--    android:layout_toRightOf="@id/CourseSchedule" --> 
<!--    /> --> 
      </RelativeLayout> 

      <WebView 
       android:id="@+id/tab2" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       /> 

     </FrameLayout> 

     <TabWidget 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0" 
      /> 

    </LinearLayout> 

</TabHost> 

모든 아이디어/제안 : 여기

내 레이아웃 코드인가?

+0

코드를보다 읽기 쉽게 포맷했습니다. 특히이 문제가 귀하의 문제인지는 모르겠지만 XML 태그 내에 주석 줄 ('')을 사용할 수는 없습니다. 블록을 주석 처리하기 위해서는' ->'로 끝나야합니다. – kcoppock

+0

문제점에 영향을 미치지 않았던 형식화 팁을 주셔서 감사합니다. Eclipse에서 토글 주석 기능을 사용하고있었습니다. – Brandon

답변

0

필자가 탭으로 가져야 만하는 경우가 아니라면 4 개의 탭을 별도의 액티비티로 분할하는 것이 좋습니다. 탭으로 만들려면 탭에 포커스가있을 때 탭 내용을 동적으로로드하십시오.

0

레이아웃 객체가 너무 많습니다. 나는 당신이 단지 TabHost와 RelativeLayout으로 모든 것을 할 수 있어야한다고 생각합니다.

+0

나는 당신의 제안을 따르고 LinearLayout을 제거하려고 시도했다. 그러나 탭 위젯은 하단 대신 상단에 배치되고 나머지보기가 전체 화면을 채우므로 탭 위젯이보기의 일부를 차단합니다. 내가 읽은 것부터 LinearLayout과 FrameLayout을 가질 필요가 없습니까? 내가보기에 일하기 위해 모든 것을 제거하기 위해 제거 할 수있는 다른 부분이 무엇인지 잘 모르겠다. – Brandon

+0

수정 : LinearLayout은 실제로 아무런 변화도 없다. 실제로 다시 저장하지 않았다. – Brandon

관련 문제