2012-04-20 3 views
0

화면의 하단에 레이아웃의 다른 뷰 요소 아래에 두 개의 버튼이있는 TableRow를 배치하려고하지만 거기에 배치하면 TableRow가 사라집니다 화면의. 나는 정상이나 중간에 아무런 문제가 없다.TableLayout을 사용하여 화면/레이아웃의 하단에 뷰 배치

나는 layout_gravity, 중력 및 무게 조합을 많이 시도했지만 얻을 수 없습니다. 사전에

감사합니다.

screenshot of the layout

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

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:gravity="center_horizontal" 
    android:text="@string/traza" 
    android:layout_margin="10sp"/> 

    <TableRow 
     android:id="@+id/tableRow8" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="3sp" 
     android:gravity="center" 
     android:weightSum="2" > 

     <Button 
      android:id="@+id/reiniciar" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_margin="5sp" 
      android:background="@drawable/bordebutton" 
      android:text="@string/reiniciar" /> 

     <Button 
      android:id="@+id/comprobar" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_margin="5sp" 
      android:background="@drawable/bordebutton" 
      android:text="@string/comprobar" /> 

    </TableRow> 

<android.gesture.GestureOverlayView 
    android:id="@+id/gestures" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fadeEnabled="true" 
    android:fadeOffset="3000" 
    android:gestureStrokeType="multiple" 
    android:eventsInterceptionEnabled="true" 
    android:orientation="vertical"/> 
</LinearLayout> 

답변

2

이 작업을 수행하려면 RelativeLayout을 사용해야합니다. ,

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10sp" 
     android:gravity="center_horizontal" 
     android:text="@string/traza" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 

    <TableRow 
     android:id="@+id/tableRow8" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="3sp" 
     android:gravity="center" 
     android:weightSum="2" 
     android:layout_alignParentBottom="true" > 

     <Button 
      android:id="@+id/reiniciar" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="5sp" 
      android:layout_weight="1" 
      android:background="@drawable/bordebutton" 
      android:text="@string/reiniciar" /> 

     <Button 
      android:id="@+id/comprobar" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="5sp" 
      android:layout_weight="1" 
      android:background="@drawable/bordebutton" 
      android:text="@string/comprobar" /> 
    </TableRow> 

    <android.gesture.GestureOverlayView 
     android:id="@+id/gestures" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:eventsInterceptionEnabled="true" 
     android:fadeEnabled="true" 
     android:fadeOffset="3000" 
     android:gestureStrokeType="multiple" 
     android:orientation="vertical" /> 

</RelativeLayout> 
+0

작동하지 않습니다. (04-21 17 : 05 : 06.363 : E/AndroidRuntime (20964) : java.lang.RuntimeException : 활동을 시작할 수 없습니다. ComponentInfo {es.hsk.ap/es.hsk.ap .juega.Trazos} : java.lang.ClassCastException : android.gesture.GestureOverlayView – Pelanes

+0

그런 다음 레이아웃에서'android.gesture.GestureOverlayView'를 제거하고 프로젝트를 지운 다음 실행하십시오. 실제로 ** GestureOverlayView **를 레이아웃 자신이 이미 레이아웃에 언급되어 있습니다. 충돌이 발생하면 어떻게 실행 했습니까? – waqaslam

+0

처음에 말했던 것처럼 LineaLayout을 RelativeLayout으로 변경하면 충돌이 발생합니다.이 뷰를 제거 할 수 없습니다. 필요합니다. 그리고 문제는 그렇지 않습니다. 중간에 다른 레이아웃을 사용하면 이미지 뷰 – Pelanes

0

편집 :이 루트 요소가 있어야 할 그 View에 포함 된 기능을 사용하려면 TableLayout. 현재 LinearLayout으로 설정되어 있습니다.

아무런 언급이없는 방법이 없습니다. TableRow보기가 세로로 배치 된 documentation입니다.

내 경험에 의하면 TableLayout은 항상 마지막 행 바로 아래에 물건을 배치합니다.

RelativeLayout 또는 LinearLayout을 사용하여 필요한 것을 얻으려고 시도 했습니까? TableLayout보다 훨씬 유연합니다.

TableLayout을 닫고 LinearLayout을 그 아래에 둘 수 있습니다.

+0

내가 대신 TableRow하지만 같은 문제, 그것에 개체보기를의 LinearLayout을 시도 모든 화면 크기를 사용 :이

는 당신은 간다. 나는 모든 avaible 화면을 사용하고 싶지만이 두 버튼은 레이아웃 하단에 표시됩니다. 감사! – Pelanes

관련 문제