2017-11-12 13 views
0

Xamarinで簡単なリンクメニューを作成する際に問題があります。必要なレイアウトは、画像ヘッダー、リンクのリスト、およびメニューを閉じるための下部のボタンです。私はリンクを表示するためにListViewを使用しています。Xamarin/AndroidでListViewメニューを作成する際の問題

私のレイアウトはVisual Studio Designerに表示されますが、エミュレータまたは実際のAndroidデバイスで実行すると、ListViewは画面全体を占め、ヘッダーとフッターは表示されません。私は、いくつかの異なるレイアウトを含め、私が考えることができるすべてを試して、常に同じ結果を得る。

私のXAMLは以下の通りです。助けて?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:minWidth="25px" 
android:minHeight="25px" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/linearLayout1"> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/topLayout"> 
    <Toolbar 
     android:minHeight="?android:attr/actionBarSize" 
     android:background="?android:attr/colorPrimary" 
     android:minWidth="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/toolbar1"> 
     <ImageView 
      android:src="@drawable/logo1" 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="1.0dp" 
      android:layout_gravity="center" /> 
    </Toolbar> 
</LinearLayout> 
<ListView 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:id="@+id/android.r." 
    android:background="#ffffffff" /> 
<LinearLayout 
    android:orientation="vertical" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/linearLayout2"> 
    <Toolbar 
     android:minHeight="?android:attr/actionBarSize" 
     android:background="#ffff8902" 
     android:minWidth="25px" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:id="@+id/toolbar3" 
     android:layout_alignParentBottom="true" 
     android:layout_marginTop="0.0dp"> 
     <Button 
      android:text="^" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/menuCloser" 
      android:layout_gravity="center" 
      android:layout_marginLeft="0.0dp" 
      android:layout_marginRight="0.0dp" 
      android:textSize="40dp" 
      android:background="?android:attr/selectableItemBackground" 
      android:ems="1" 
      android:onClick="OnCloseMenu" 
      android:shadowColor="@android:color/transparent" 
      android:textColor="#ffffffff" /> 
    </Toolbar> 
</LinearLayout> 
</LinearLayout> 

答えて

0

さらに多くのアイテムがある場合は、下に移動してフッターを表示する必要があります。ビジュアルスタジオデザイナーは、ヘッダーとフッターを見ることができるように、より少ないアイテムでサンプルリストを表示します。フッターを固定したい場合、スクロールしたくない場合は相対レイアウトを使用します。

+0

を削除し、しかし、私はこのケースだったが、そうでない場合は上部のツールバーや画像を表示するように期待します。私はまた、ListViewに全く追加されていない項目でそれを実行しようとしましたが、同じ動作をしました。私が何をしても、画面全体がListViewで塗りつぶされます。 – plunkg

0

ちょうどあなたのリストビューのタグを置き換えることにより、

<ListView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:id="@+id/android.r." 
     android:background="#ffffffff" /> 

1>問題は、あなたが重量を使用している場合、それは0dpする必要がありますあなたのandroid:layout_height="0dp"にありました。

2>私の提案は、あなたがListView

3に多くの矛盾に直面するだろうとアンドロイドのRecyclerViewを使用することです>あなたのコード私はあなたがそう提案iと

をAndroidに新しいいると思うと、クリーンアップする必要があります確かに理にかなって、いくつかの未使用のプロパティ、

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/linearLayout1"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/topLayout"> 
     <Toolbar 
      android:background="?android:attr/colorPrimary" 
      android:layout_width="match_parent" 
      android:layout_height="?android:attr/actionBarSize" 
      android:id="@+id/toolbar1"> 
      <ImageView 
       android:src="@drawable/ic_back" 
       android:id="@+id/imageView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       /> 
     </Toolbar> 
    </LinearLayout> 
    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:id="@+id/android.r." 
     android:background="#ffffffff" /> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/linearLayout2"> 
     <Toolbar 
      android:minHeight="?android:attr/actionBarSize" 
      android:background="#ffff8902" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/toolbar3" 
      > 
      <Button 
       android:text="^" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/menuCloser" 
       android:layout_gravity="center" 
       android:layout_marginLeft="0.0dp" 
       android:layout_marginRight="0.0dp" 
       android:textSize="40dp" 
       android:background="?android:attr/selectableItemBackground" 
       android:ems="1" 
       android:onClick="OnCloseMenu" 
       android:shadowColor="@android:color/transparent" 
       android:textColor="#ffffffff" /> 
     </Toolbar> 
    </LinearLayout> 
</LinearLayout> 
+0

提案していただきありがとうございますが、残念ながらこれで問題は解決されませんでした。 – plunkg

関連する問題