2011-11-03 3 views
1

안드로이드 인터페이스를 만들려고하는데, 약간의 중복 문제가 있습니다.안드로이드에서 원하지 않는 중첩을 제거하는 방법

여기 내 코드입니다. 그것은 Tab에 있지만 Tab 부분을 멀리 잘라냅니다. 필요한 경우 추가하겠습니다.

업데이트 : 나는뿐만 아니라, 하나의

<FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp" > 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

      <ScrollView 
       android:orientation="vertical" 
       android:layout_height="fill_parent" 
       android:layout_width="fill_parent"> 

       <LinearLayout 
        android:orientation="vertical" 
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent"> 

       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" /> 

       <!-- A lot of TextView as the one above --> 

       </LinearLayout> 
      </ScrollView> 

      <RelativeLayout 
       android:id="@+id/InnerRelativeLayout" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" > 

       <Button 
        android:id="@+id/add" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_width="fill_parent" 
        android:text="@string/add" /> 
      </RelativeLayout> 
     </RelativeLayout> 
    </FrameLayout> 

을 텍스트 뷰의 여지가 있음을 쓰는 것을 잊었 그리고 이것은 출력하는 것입니다. 당신이 볼 수 있듯이, 하단에 텍스트 버튼 뒤에 간다,하지만 난 두 개의 서로 다른 레이아웃

Screenshot

+0

환영 인사는 어디에서 왔습니까? –

+0

코드를 업데이트했습니다. TextView가 많이 있지만 코드에 그 중 하나만 쓰면 코드가 더 짧아집니다. –

답변

2

시도가 상대적으로 버튼 위에 올려 놓으있는 가정, 당신이있는 ScrollView 안에있는 LinearLayout를 덤프 할 수 있다고 생각 .

<RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

     <ScrollView     
      android:orientation="vertical" 
      android:layout_above="@+id/InnerRelativeLayout" //Add this 
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent"> 

      <LinearLayout 
       android:orientation="vertical" 
       android:layout_height="fill_parent" 
       android:layout_width="fill_parent"> 

      <TextView 
       android:text="welcome" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" /> 

      </LinearLayout> 
     </ScrollView> 

     <RelativeLayout 
      android:id="@+id/InnerRelativeLayout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" > 

      <Button 
       android:id="@+id/add" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_width="fill_parent" 
       android:text="@string/add" /> 
     </RelativeLayout> 
    </RelativeLayout> 
</FrameLayout> 
+0

시도해 보았지만 버튼이 사라졌습니다. –

+0

그런 다음 수정 된 버전을 사용해보십시오. – Peterdk

+0

이것은 RelativeLayout을 사용하지 않는 이유입니다. ScrollView의 'fill_parent'높이가 엉망이됩니다. 당신은 계속 그것을 두드리고, 결국 그 기능을 발휘할 것입니다. 아니면 그냥 LinearLayout과 무게를 사용하십시오. –

0

에서 그들을 갖고 싶어 당신이 절대적으로 필요하지 않는 한 RelativeLayout의를 사용하지 마십시오. 이제까지. 나는 이것이 대중적인 의견이 아니라는 것을 알고 있지만, 그것이 내가 모두에게 말하는 것입니다.

가능한 한 많은 공간을 차지하도록 스크롤 한 다음 하단에 단추가 있어야한다고 가정합니다.

<LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 

      <ScrollView 
       android:layout_height="wrap_content" 
       android:layout_width="fill_parent" 
       android:layout_weight="1"> 
       <LinearLayout 
       android:layout_height="wrap_content" 
       android:layout_width="fill_parent" 
       android:orientation="vertical"> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 
       <TextView 
        android:text="welcome" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"/> 

       </LinearLayout> 
      </ScrollView> 

       <Button 
        android:id="@+id/add" 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent" 
        android:text="@string/add" /> 

     </LinearLayout> 

나는 당신이 단지 1 아이합니다 (텍스트 뷰)

+0

글씨를 쓰는 것을 잊어 버렸지 만 이미지에서 볼 수 있듯이 (예를 들어 TextView에서) 많은 위젯을 가지고 있습니다. 스크롤 뷰 –

+0

확인. 그냥 LinearLayout을 ScrollView에 두십시오. –

+0

LinearLayout은 이미 있습니다. –

관련 문제