2014-02-19 4 views
1

저는 잠시 동안이 문제에 시달렸으며 지금까지 답변을 찾을 수 없었습니다. RelativeLayout 안에 TableLayout이 있습니다. TableLayout을 스크롤 할 수 있도록해야합니다. 상대적 레이아웃이 아니기 때문에 정적 버튼이있어서 움직이는 것을 계획하지 않습니다. 중첩 된 레이아웃 ScrollView

<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:scrollbars="vertical" 
android:layout_weight="1"> 
    <RelativeLayout 
android:id="@+id/RelativeLayout1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".Encuestas" > 
    <Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginRight="14dp" 
    android:layout_marginTop="14dp" 
    android:onClick="SyncServer" 
    android:text="Sync" /> 

     <TableLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:id="@+id/TableLayout1" 
    android:layout_alignParentRight="true" 
    android:layout_below="@+id/button1" > 

     </TableLayout> 


</RelativeLayout> 
</ScrollView> 

이 코드와 나는 전체 화면을 스크롤 할 수 있습니다,하지만 난 TableLayout을에있는 ScrollView를 넣어하려고하면, 나는 내가 만든 버튼을 클릭 드릴 수 없습니다.

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".Encuestas" > 

    <Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginRight="14dp" 
    android:layout_marginTop="14dp" 
    android:onClick="SyncServer" 
    android:text="Sync" /> 
    <ScrollView 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical" 
    android:layout_weight="1"> 
    <TableLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:id="@+id/TableLayout1" 
    android:layout_alignParentRight="true" 
    android:layout_below="@+id/button1" > 


</TableLayout> 

    </ScrollView> 
    </RelativeLayout> 

이 버튼을 클릭하면 허용되지 않습니다. 어떤 제안?

+0

을 나는 그것이 사실로 인해 아마 생각 ScrollView''그 'Button' 다음에 레이아웃에 추가되고 부모의 높이와 너비가 일치하도록 설정되어 z- 인덱스의'Button'보다 위에 있습니다. 'ScrollView' 다음에'Button'을 추가하십시오. –

+0

감사합니다. Manveer Chawla. 나는 ScrollView가 버튼 앞에 있다는 사실을 잊어 버렸습니다. –

+0

이 방법이 효과가 있다면 답변으로 게시해야합니까? :) –

답변

1

다른 화면으로 스크롤 할 수있는보기를 두지 마십시오 (같은 방향으로 스크롤). 이 규칙에 대한 유일한 예외는 주님 께서 당신 앞에서 모든 영광 가운데 나타나 시어 달리 말할 수있는 돌판을 새기 셨을 때입니다.

어쨌든, 두 번째 레이아웃은 하나의 작은 수정과 함께 작동합니다, 당신과 같이 버튼 아래에있는 ScrollView를 넣어 레이아웃을 알려야합니다 :

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical" 
    android:layout_below="@id/button1" 
    android:layout_weight="1"> 
+0

완벽한 답변! 매력처럼 일했습니다. 또한 Manveer Chawla의 작품 논평 –