2017-03-21 19 views
0

私はXamarinとAndroidアプリケーションのレイアウトに苦労しています。私は、以下のコードに示すようにListViewを持っていますが、複数の都市でそれを設定するたびに、ListViewは展開されません。代わりに、私はそれをスクロールする必要がありますが、高さは一度に1つの項目を表示するだけです。ListViewの高さがコンテンツに調整されていません

私が本当に欲しいのは、ListViewにはより多くのアイテムが含まれているため、展開することです。しかし同時に、私はキーボードがEditTextフィールドをカバーすることを望んでいません。スクロールビュー内にすべてを配置し、ListViewのlayout_heightをwrap_contentに設定するなど、Everythingを試したと感じています。しかし、それは動作しません。

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/scrollView1"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:paddingLeft="15px" 
     android:paddingRight="15px" 
     android:paddingBottom="15px" 
     android:paddingTop="15px" 
     android:id="@+id/linearLayout1"> 
     <TextView 
      android:text="Select algorithm:" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView1" /> 
     <RadioGroup 
      android:minWidth="25px" 
      android:minHeight="25px" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/radioGroup1" 
      android:animateLayoutChanges="true" 
      android:orientation="horizontal"> 
      <RadioButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:checked="true" 
       android:text="Greedy Best first Search" 
       android:id="@+id/radioButton1" /> 
      <RadioButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="A* Best First Search" 
       android:id="@+id/radioButton2" /> 
     </RadioGroup> 
     <TextView 
      android:text="Add location coordinates:" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/linearLayout2" 
      android:paddingTop="30px" /> 
     <ListView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/listViewCoords" /> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 
      <EditText 
       android:inputType="numberDecimal" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="left" 
       android:layout_weight="1" 
       android:id="@+id/editTextX" /> 
      <EditText 
       android:inputType="numberDecimal" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="right" 
       android:layout_weight="1" 
       android:id="@+id/editTextY" /> 
     </LinearLayout> 
     <Button 
      android:text="Add" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/buttonAdd" /> 
     <Button 
      android:text="Clear all" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/buttonClear" /> 
     <Button 
      android:text="Find shortest path" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/buttonSearch" /> 
    </LinearLayout> 
</ScrollView> 

答えて

0

リストビューはScrollView下に置かれてはなりません。あなたのコードに他の問題はありません。

0

ListViewをScrollViewに使用しないでください。それは多くの点で間違っている。

あなたは、スクロール可能なコンテンツの中にリストを使用しRecyclerViewを使用してNestedScrollViewでそれらをラップします。

関連する問題