2017-03-26 15 views
0

현재 Android 6에서 실행되는 Android 애플리케이션을 개발 중입니다. Android 개발에 완전히 익숙하지만 WPF 경험이 조금 있습니다. 비슷하다.TableRow에서 안드로이드 관련 레이아웃과 Linear 레이아웃이있는 TableRow

enter image description here

이 내가 현재이 문제를 해결해야하는 XML입니다 : 다음은 내가처럼 보이게보기를 원하는 것입니다 큰 장치에서 잘 작동

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/activity_guimain" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:weightSum="2" 
    tools:context="indoorpilot.indoorpilot.GUIMain"> 
    <TableRow> 
     <!--android:layout_width="match_parent">--> 
     <TextView 
      android:id="@+id/textView" 
      android:layout_weight="1" 
      android:gravity="center_horizontal" 
      android:text="Building Label"/> 
    </TableRow> 


    <TableRow> 
     <RelativeLayout 
      android:layout_weight="1"> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       app:srcCompat="@drawable/mclaurysecondfloor" 
       android:id="@+id/imageView2"/> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       app:srcCompat="@android:drawable/presence_online" 
       android:="@+id/markerImage"/> 

     </RelativeLayout> 
    </TableRow> 

    <TableRow> 
     <LinearLayout 
      android:layout_weight="1" 
      style="?android:attr/buttonBarStyle"> 
      <Button 
       style="?android:attr/borderlessButtonStyle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="@string/contextual_info" 
       android:onClick="ShowContextualInformation"/> 
      <Button 
       style="?android:attr/borderlessButtonStyle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="@string/scan_button" 
       android:onClick="SetRSSIDistanceValues"/> 
     </LinearLayout> 
    </TableRow> 
</TableLayout> 

(태블릿).하지만 Android Studio View 렌더러 또는 다른 유형의 휴대 전화에서는 제대로 표시되지 않습니다. RelativeLayout을 포함하는 TableRow가 전체 화면을 차지하므로 결국 버튼이 표시되지 않습니다.

+0

부모로서'TableLayout' 대신에'RelativeLayout'을 사용하십시오. 상단 행을 부모 행과 하단 행을 부모 행 아래에 맞 춥니 다. 'RelativeLayout'은 모든 정렬을 제공합니다. –

답변

2

외부 Android Studio를 완료했지만 도움이 될 수 있습니다. 필요한 경우 편집 할 수 있습니다.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/activity_guimain" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:weightSum="2" 
    tools:context="indoorpilot.indoorpilot.GUIMain"> 

    <TextView 
     android:id="@+id/textView" 
     android:gravity="center_horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Building Label"/> 



     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/textView" 
      android:layout_above="@+id/buttons_container" 
      app:srcCompat="@drawable/mclaurysecondfloor" 
      android:id="@+id/imageView2"/> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/textView" 
      app:srcCompat="@android:drawable/presence_online" 
      android:id="@+id/markerImage"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_below="@+id/imageView2" 
     android:layout_height="wrap_content" 
     android:layout_orientation="horizontal" 
     android:id="@+id/buttons_container" 
     style="?android:attr/buttonBarStyle"> 
     <Button 
      style="?android:attr/borderlessButtonStyle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="@string/contextual_info" 
      android:onClick="ShowContextualInformation"/> 
     <Button 
      style="?android:attr/borderlessButtonStyle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="@string/scan_button" 
      android:onClick="SetRSSIDistanceValues"/> 
    </LinearLayout> 

</RelativeLayout> 

TableLayout은 필요하지 않습니다. 필요한 것은 RelativeLayout이며 상단에는 TextView, 하단에는 두 개의 버튼이 포함 된 ImageViewLinearLayout이 있습니다. 작은 화면 크기의 경우 RelativeLayout이 포함 된 ScrollView이 필요할 수 있습니다.