2011-01-25 7 views
0

나는 이미 레이아웃 문제에 몇 시간을 보냈다. 다른 사람이 동일한 활동에서 이미지 및보기 스위처를 모두 표시하는 방법을 알려줄 수 있습니까?android xml 레이아웃 문제

<RelativeLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:myapp="http://schemas.android.com/apk/res/rg.client.muscle" 
      android:layout_width="fill_parent" 
     android:layout_height="fil_parent"> 
    <ViewSwitcher 
     android:id="@+id/relative" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true"> 

     <!-- contains two relative layouts of same sizes 
     containing same elements just with switched positions --> 

     <RelativeLayout 

      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" > 

      <com.admob.android.ads.AdView 
       android:id="@+id/adv" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       myapp:backgroundColor="#000000" 
       myapp:primaryTextColor="#FFFFFF" 
       myapp:secondaryTextColor="#CCCCCC" 
       myapp:refreshInterval="30" > 
      </com.admob.android.ads.AdView> 

      <LinearLayout 
       android:id="@+id/linear" 
       android:orientation="horizontal" 
       android:weightSum="100" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@id/adv" > 

       <Button 
        android:id="@+id/but_prev2" 
        android:text="Previous" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="30" > 
       </Button> 

       <Button 
        android:id="@+id/but_more2" 
        android:text="More" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="40" > 
       </Button> 

       <Button 
        android:id="@+id/but_next2" 
        android:text="Next" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="30"> 
       </Button> 
      </LinearLayout> 
     </RelativeLayout> 

     <RelativeLayout 

      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" > 

      <LinearLayout 
       android:id="@+id/linear2" 
       android:orientation="horizontal" 
       android:weightSum="100" 
       android:layout_width="fill_parent"  
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" > 

       <Button 
        android:id="@+id/but_prev" 
        android:text="Previous" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="30"> 
       </Button> 

       <Button 
        android:id="@+id/but_more" 
        android:text="More" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="40"> 
       </Button> 

       <Button 
        android:id="@+id/but_next" 
        android:text="Next" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="30"> 
       </Button> 

      </LinearLayout> 

      <com.admob.android.ads.AdView 
       android:id="@+id/adv2" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@id/linear2" 
       myapp:backgroundColor="#000000" 
       myapp:primaryTextColor="#FFFFFF" 
       myapp:secondaryTextColor="#CCCCCC" 
       myapp:refreshInterval="30"> 
      </com.admob.android.ads.AdView> 
     </RelativeLayout> 
    </ViewSwitcher> 

    <ImageView 
     android:id="@+id/image" 
     android:layout_above="@id/relative" 
     android:padding="2pt" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" > 
    </ImageView> 
</RelativeLayout> 

내가 먼저 새로운 이미지 버튼이 사라지고 전체 레이아웃이 팽창 다시 것 같다로드 할 때마다 이미지 뷰를 넣으면

업데이트 :

레이아웃은 이미지보기를해야합니다 상단에는보기 전환기가 있습니다.

답변

0

XML을 읽을 수 없다는 것이 많은 상상입니다. 원래 여기에 붙여 넣은 것과 비슷한 것처럼 보이는 경우입니다. 첫 번째 문제는 루트 RelativeLayout 태그에 크기를 지정하지 않은 것입니다. 대부분의 경우 루트 레이아웃은 layout_widthfill_parent이고 layout_height과 동일해야합니다. 또한 실제로 스키마를 컴파일하기 때문에 스키마 사양 (예 : xmlns:android="http://schemas.android.com/apk/res/android")이 필요합니다.

대부분의 항목은 wrap_content으로 설정되어 있으므로주의해야 할 수도 있습니다. 높이의 경우 화면 높이를 초과하면 일부가 보이지 않으므로 ScrollView에 내부 부분을 배치하는 것이 좋습니다.

EDIT : 다시 말해서 RelativeLayout (root 요소)의 높이가 fill_parent이되도록하십시오. 먼저 ImageView를 정의하고 alignParentTop="true"으로 남겨두고 ViewSwitcher를 정의한 다음 layout_below="@id/image" 속성을 지정하십시오.

+0

죄송합니다. 여기에 말씀하신 내용을 추가하지 않았습니다. 그러나 그들은 모두 코드에 설정되어 있습니다. – JehandadK

+0

정확한 답변을 원할 경우 추가해야합니다. ViewSwitcher에'android : layout_below = "@ id/image"'를 추가하십시오. 레이아웃과 내용을 알지 못하면 말하기 어렵습니다. 또한 RelativeLayouts에는'android : orientation' 속성이 없으며 LinearLayout 만 있습니다. 그것들을 사용하면 RelativeLayout에 영향을 미치지 않습니다. – kcoppock

+0

고정하고 이미지가 있어야하는 부분도 추가했습니다. – JehandadK

0

작은 조언과 함께 레이아웃을 사용하면 더 명확 해집니다.

<include layout="@layout/my_other_layout" /> 
+0

나는 그것을 따라 가고 싶다. 지금 나는 사건들과 모든 것을 다루는데 어려움을 겪고있다. include를 사용하여 같은 레이아웃으로 배치하면 버튼의 ID를 어떻게 얻을 수 있습니까? – JehandadK