1

にいくつかのアイテムがあり、 の下Listviewに を配置しました。ImageButtonlistview

android:src ="@drawable/view1"すべてのアイテムを取得してスクロールを使用できる場合。

しかし、 srcの代わりにバックグラウンドを使用するときはいつでも

android:background="@drawable/view1"画像ボタンでスクロールが効かないのですがなぜですか?

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#ffffff">

 <include
    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    layout="@layout/header"/>

<ListView android:layout_height="wrap_content"
    android:layout_weight="1" android:id="@+id/listView1"
    android:layout_width="fill_parent" 
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="20dp"
    android:cacheColorHint="#00000000"
    android:divider="#00000000"
    android:dividerHeight="20dp"/>


<ImageButton 
    android:layout_width="wrap_content" 
    android:id="@+id/ButtonViewCart"
    android:layout_height="wrap_content" 
    android:background="@drawable/view1"
    android:layout_margin="5dip"
    android:layout_gravity="right"/>

  </LinearLayout>
4

2 に答える 2

5

ListView はデフォルトでスクロール可能です。ListViews 内の項目数が画面に表示できる量を超えると、スクロールが自動的に行われます。

于 2012-11-05T06:45:56.767 に答える
-1

<ScrollView>ルートノードとして作成し、これを試してください:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/mainbk" >

<LinearLayout
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#ffffff">

 <include
    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    layout="@layout/header"/>

<ListView android:layout_height="wrap_content"
    android:layout_weight="1" android:id="@+id/listView1"
    android:layout_width="fill_parent" 
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="20dp"
    android:cacheColorHint="#00000000"
    android:divider="#00000000"
    android:dividerHeight="20dp"/>


<ImageButton 
    android:layout_width="wrap_content" 
    android:id="@+id/ButtonViewCart"
    android:layout_height="wrap_content" 
    android:background="@drawable/view1"
    android:layout_margin="5dip"
    android:layout_gravity="right"/>

  </LinearLayout>

</ScrollView>
于 2012-11-05T06:42:22.720 に答える