2013-04-09 1 views
0

Scrollview에서 하나의 하위 만 호스팅 할 수 있다는 오류가 표시됩니다. 내가하려는 것은 전체 인터페이스가 스크롤하여 맨 위의 광고를 빼도록하는 것입니다. 이제는 선형 레이아웃에서 광고를 볼 수 있습니다. 스크롤 레이아웃은 그 안에 있습니다. scrollview 내부에는 또 다른 선형 레이아웃이 있으며 그 외 모든 것은 그 안에 있습니다. 나는 무엇을 해야할지를 놓치고 있습니다. 스크롤해야하는 광고가 정말로 필요하지만 스크롤 코드 안에 광고 코드를 넣어야한다면 그렇게 할 것입니다. 나는 그것을 발견 할 수 없지만 내가 원하는 것을 할 수있는 방법이 있다는 것을 확신한다. 더 이상 도움이 필요한 경우상단에 광고가 스크롤되지 않는 스크롤보기

여기이 완벽하게 작동 나를 위해

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:id="@+id/AdLinearLayout" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<!-- Ad Placeholder --> 

<com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="a15138b1a7adad2" 
    ads:loadAdOnCreate="true" /> 

<ScrollView 
    android:id="@+id/BaseScrollView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:id="@+id/baseVerticalLinearLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:id="@+id/LinearLayoutH1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="left" 
       android:text="@string/Sad" /> 

      <TextView 
       android:id="@+id/textView2" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="right" 
       android:text="@string/Happy" /> 
     </LinearLayout> 

     <SeekBar 
      android:id="@+id/happinessBarID" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:max="@integer/SliderMax" 
      android:progress="@integer/SliderDefault" /> 

     <LinearLayout 
      android:id="@+id/LinearLayoutH2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/textView3" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="left" 
       android:text="@string/Tired" /> 

      <TextView 
       android:id="@+id/textView4" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="right" 
       android:text="@string/Awake" /> 
     </LinearLayout> 

     <SeekBar 
      android:id="@+id/energyBarID" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:max="@integer/SliderMax" 
      android:progress="@integer/SliderDefault" /> 

     <LinearLayout 
      android:id="@+id/LinearLayoutH3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/textView5" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="left" 
       android:text="@string/Calm" /> 

      <TextView 
       android:id="@+id/textView6" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="right" 
       android:text="@string/Anxious" /> 
     </LinearLayout> 

     <SeekBar 
      android:id="@+id/anxietyBarID" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:max="@integer/SliderMax" 
      android:progress="@integer/SliderDefault" /> 

     <LinearLayout 
      android:id="@+id/LinearLayoutH4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/textView7" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="left" 
       android:text="@string/No_Pain" /> 

      <TextView 
       android:id="@+id/textView8" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="right" 
       android:text="@string/Max_Pain" /> 
     </LinearLayout> 

     <SeekBar 
      android:id="@+id/painBarID" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:max="@integer/SliderMax" 
      android:progress="@integer/SliderDefault" /> 

     <DatePicker 
      android:id="@+id/datePicker1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <TimePicker 
      android:id="@+id/timePicker1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <EditText 
      android:id="@+id/noteTextFieldID" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:hint="@string/Note_Hint" 
      android:inputType="textMultiLine" 
      android:maxLength="@integer/NoteLimit" /> 

     <Button 
      android:id="@+id/enterButtonID" 
      android:layout_width="132dp" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:onClick="dialogPop" 
      android:text="@string/EnterButtonText" /> 
    </LinearLayout> 
</ScrollView> 

</LinearLayout> 
+0

작동하지 않는 기능은 무엇입니까? – nhaarman

+0

ScrollView에는 자식이 하나만 있습니다 ...이 파일을 다시 저장하고 프로젝트를 정리하는 중입니다. – Sam

+0

나는 그것을 시도 할 것이다. 스크롤 뷰를 좋아하지 않는 이유를 알 수는 없지만 한 번만 청소 해 보겠습니다. (비록 내가 올바르게 기억한다면, 나는 이것에 대해 작업하는 동안 어제 몇 번 프로젝트를 정리했다.) 당신이 화면에 나타나는 행동은 무엇입니까? (지금 당신의 포스트에서와 같이) 레이아웃이있는 – fauxfire76

답변

1

여기 AdMob의 Ad Catalog 프로젝트의 예를있는 ScrollView 레이아웃의 약간 수정 된 버전입니다 com.google.ads.AdView 아래에 앉아 있습니다.

+0

감사합니다. 이제 UI를 수용하기 위해 UI를 아래로 이동하는 대신 내 응용 프로그램 위에 광고를 오버레이하려고한다는 사실을 제외하고 UI가 잘 작동하도록 할 수있었습니다. 내가 어떻게 그런 일이 일어나야하는지 아는 어떤 생각? – fauxfire76

+0

이 줄을 ScrollView 또는 AdView의 형제 요소 인'android : layout_below = "@ id/adView"'에 추가 했습니까? 그렇게 처리해야합니다. –

0

... 내 XML 레이아웃입니다, 제발 말해. 명시 적으로 말하고 싶은, 그래서 당신은 광고가 ScrollView 위에 싶지 않아

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <com.google.ads.AdView android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     ads:adUnitId="@string/admob_id" 
     ads:adSize="BANNER"/> 
    <ScrollView android:id="@+id/scrollLayout" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_below="@id/adView"> 
     <LinearLayout android:layout_height="fill_parent" 
      android:layout_width="fill_parent"> 
      <TextView android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="@string/advancedLayouts_scroll_view_lorem_ipsum"/> 
     </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 

:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="xxxxxx" /> 

    <RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <ScrollView 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/scrollView" 
      android:layout_width="fill_parent" 
      android:layout_height="match_parent" 
      android:background="@drawable/back3" > 

      <LinearLayout 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:gravity="center_horizontal" 
       android:orientation="vertical" > 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="top|center_horizontal" 
        android:layout_marginTop="5dp" 
        android:text="Text" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical|center_horizontal" 
        android:layout_marginBottom="20dp" 
        android:text="Text2" /> 
      </LinearLayout> 
     </ScrollView> 
    </RelativeLayout> 

</LinearLayout> 
+0

외부 Linearlayout과 scrollview 사이에 relativelayout 레이어가있는 것과 다른 점은 무엇입니까? – fauxfire76

관련 문제