1

これは私のレイアウトです:

<?xml version="1.0" encoding="utf-8"?>
        <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/scrollViewContact"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:fillViewport="true">
    <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:id="@+id/contactOuterLayout"
    >

    <RelativeLayout 
        android:layout_height="fill_parent"
        android:id="@+id/contactOuterRelativeLayout" 
        android:layout_width="fill_parent"
        android:background="@drawable/radialback">



            <RelativeLayout android:id="@+id/relativeLayout1"
                android:layout_height="wrap_content"                     
                android:layout_width="fill_parent"
                android:layout_below="@+id/tableLayout1" 
                android:paddingBottom="10sp">

                <TableLayout
                    android:id="@+id/contactdetails"
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:stretchColumns="*" >
                        
                    <TableRow 
                        android:id="@+id/mapView"
                        android:layout_height="wrap_content"
                        android:layout_width="fill_parent"
                        >
                        <LinearLayout 
                            android:id="@+id/liny"
                            android:layout_height="match_parent"
                            android:layout_width="match_parent"
                            android:orientation="horizontal"
                            android:weightSum="100">

                            <com.google.android.maps.MapView
                                 android:id="@+id/map"
                                 android:layout_height="100dp"
                                 android:layout_width="100dp"
                                 android:layout_marginLeft="20dp"
                                 android:layout_marginTop="15dp"
                                 android:enabled="true"
                                 android:clickable="true"
                                 android:apiKey="00n1pmS8eEhXhD5a6Q3UTDd6zortw9t4l_jXioQ"
                                />
                            
                <TextView
                    android:id="@+id/MapAdrress"
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="15dp"
                    android:layout_weight="30"
                    android:text="TextView" />
                            
                        </LinearLayout>

                    </TableRow>
                    
                                                            
                    <TableRow android:layout_width="fill_parent"
                        android:layout_height="wrap_content">
                        

                        
                        <TableLayout android:id="@+id/contactinfo" 
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            >

                            

                            <TableRow android:layout_width="fill_parent"
                                android:layout_height="wrap_content">
                                <TableLayout android:id="@+id/contactinfo2" 
                                    android:layout_width="fill_parent"
                                    android:layout_height="wrap_content">
                                    <!-- Telephone number, web-site etc -->         
                                </TableLayout>                                                                      
                            </TableRow> 

            
                        
                    </TableLayout>              
                        
                    </TableRow> 
                    
                    <TableRow android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center">
                        
                        <TableLayout android:id="@+id/contactinfo" 
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            
                            >

                        <Button
                            android:id="@+id/butonek"
                            android:layout_width="10dp"
                            android:layout_height="wrap_content"
                             />
            
                    </TableLayout>
                        
                    </TableRow>

                    
                    <TableRow android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:gravity="center"
                        android:paddingTop="20dip">
                        <TableLayout android:layout_width="fill_parent"
                            android:layout_height="wrap_content">                                   
                            <TableRow android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:gravity="center_horizontal">
                                <TableLayout android:id="@+id/address" 
                                    android:layout_width="200dip"
                                    android:layout_height="wrap_content">
                                    <!-- Address -->
                                </TableLayout>
                            </TableRow>
                        </TableLayout>
                    </TableRow>                     
                    <TableRow android:layout_width="fill_parent"
                        android:layout_height="match_parent"
                        android:layout_gravity="center_horizontal"
                        android:gravity="center"
                        android:paddingTop="20dip">
                                        <ListView
                     android:id="@+id/contactlist"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent" 
                     android:choiceMode="multipleChoice"
                     />

                    </TableRow> 
                </TableLayout>
            </RelativeLayout>
        
    </RelativeLayout>
</LinearLayout>
    </ScrollView>

これは写真です:

ここに画像の説明を入力してください

リストに4つの要素がありますが、表示できるのは2つだけで、スクロールできません。リストだけでなくすべてのページをスクロールするにはどうすればよいですか?

4

3 に答える 3

2

ScrollView内にListViewを含めることはできません。ListViewには独自のScrollingの実装があるため、ScrollView内に配置すると、ScrollViewだけでなくそのScrollにも影響します。したがって、ScrollView内にListViewがないようにレイアウトを置き換えてください。

于 2012-05-16T09:28:59.107 に答える
2
        <LinearLayout 
        android:layout_height="match_parent"
        android:layout_width="match_parent">
            <ListView
                 android:id="@+id/contactlist"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent" 
                 android:choiceMode="multipleChoice"
                 />
                 </LinearLayout>

この場合、listViewをlinearlayout内に配置すると、問題が解決します。

于 2012-05-16T09:51:59.507 に答える
1

スクロールビュー内にリストビューを追加するのは良い実装ではありません。スクロールビュー内にリストビューがある場合、リストビューをスクロールすると、Androidが違いを生むのは非常に難しく、リストビューをスクロールしてもスクロールはスクロールビューによって消費されるため、リストビュー内のアイテムは持ち上げられません。したがって、スクロールビューを線形レイアウトに置き換えます。

また、レイアウトデザインを見ると、レイアウトの多くは実際には必要ないことがわかります。デザインを確認することをお勧めします。Lintは、不要なレイアウトを削除するのに役立ちます。

于 2012-05-16T09:49:04.590 に答える