2017-03-26 17 views
0

私は現在、AndroidアプリケーションをAndroid 6で実行するように取り組んでいます。私はAndroid開発に全く新しいですが、WPFの経験が少しあります。似ている。Android Relative Layout 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スタジオビューレンダラーでは正しく表示されません。また、あらゆる種類の電話で表示されます。 RelativeLayoutを含むTableRowが画面全体を占めてしまうので、ボタンは表示されません...

+0

親として 'TableLayout'の代わりに' RelativeLayout'を使用してください。あなたの一番上の行を親と下の行に親の下に揃えます。 'RelativeLayout'はすべての並べ替えを行います。 –

答えて

2

私はこのアンドロイドスタジオを外に出しましたが、必要に応じて編集することができます。

<?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、下部には2つのボタンを含むImageViewLinearLayoutの2つがあります。小さな画面サイズの場合はRelativeLayoutを含むScrollViewが必要な場合があります。

関連する問題