1

私は同じ「スクロール」でイメージとリストを取得しようとしています(それを置く方法がわかりません)。同じScrollView内のリストとイメージ

  • のTextView

  • ImageViewの

  • のListView

画像がリストであるかのように、私はスクロールを取得しようとしている:(縦)レイアウトが私の基本的なアイテム自体。テキストビューは一番上に残っていなければならず、他のものはその下にスクロールする必要があります。

私は、次のコードを持っている瞬間:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/background" 
android:orientation="vertical" > 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/app_purple" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/about_app_label" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:padding="15dp" 
     android:text="@string/about_app_label" 
     android:textColor="@color/background" 
     android:textSize="20dp" 
     android:textStyle="bold" /> 

     <ImageView 
      android:id="@+id/app_logo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/logo" /> 

</LinearLayout> 

<ListView 
    android:id="@+id/information_list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/background" 
    android:divider="@drawable/listdivider" 
    android:dividerHeight="1dp" 
    android:fadingEdge="none" > 

    <!-- Preview: [email protected]/row --> 
</ListView> 

任意の助けいただければ幸いです!

EDIT

リストビューのカスタム列レイアウト:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@color/listview" 
android:orientation="horizontal" 
android:padding="4dip" > 

<ImageView 
    android:id="@+id/list_icon" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:adjustViewBounds="true" 
    android:layout_marginRight="5dp" 
    android:contentDescription="@string/icon_content_description" /> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/list_label" 
      android:layout_width="200dp" 
      android:layout_height="wrap_content" 

      android:maxLines="1" 
      android:paddingBottom="5dp" 
      android:paddingTop="5dp" 
      android:textColor="@color/result_label" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/list_count" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:layout_toRightOf="@+id/list_label" 
      android:ellipsize="end" 
      android:gravity="center_vertical" 
      android:maxLines="1" 
      android:textColor="@color/text" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/list_result" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="center_vertical" 
      android:textColor="@color/text" 
      android:textColorLink="@color/app_purple" /> 

     <ProgressBar 
      android:id="@+id/list_progress" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:gravity="center_vertical" 
      android:visibility="gone" /> 
    </RelativeLayout> 
</LinearLayout> 

答えて

2

ListViewを固定しているLinearLayoutの垂直線があります。 ImageViewはのヘッダーで、addHeaderView()で追加されます。ヘッダーは、その名前にもかかわらず、ListViewの内容でスクロールします。

+0

ありがとう、これはまさに探していたものです。これは、あなたがこのプロジェクトで私を助けてくれた2回目です。最初はあなたの本の1つでした:)。 – Meatje

1

あなたがしたいすべてのものを配置するsingle_list_item.xmlファイルを作成する必要がありますカスタムリストビューを作成します例えば画像の横に説明テキストがあるようにスクロールします。また、プログラムがビューを処理できるように、XMLファイルにListViewを追加する必要があります。そして、それらを使用すると、アダプタを使用してjavaファイルのすべてを処理できます。リストがテキストの下部に表示されます。

は、here

+0

私はすでにlistViewのカスタム行レイアウトを持っています。しかし、私は画像を全体の行を占めるようにする可能性を見ていません。または、異なるレイアウトの1つの行を実装することは可能ですか?投稿をrow.xmlコードで更新しました。あなたの助けをありがとう。 – Meatje

+0

ImageViewをrow.xmlファイルに追加してテキストの上に描画しないでください。また、Eclipseの下のレイアウトのグラフィカルビューでは、各行がイメージでどのように見えるかを見ることができます。 –

0

それは正確に何をしようとするはっきりしていない行う方法の良い例があります。 ScrolViewは子を1つしか持てません。ですから、ImageViewとListviewをLinearLayoutに配置する必要があります。 しかし、何らかの形で - ListViewをScrollViewの中に置くことは悪い考えです。どのようにOSをスクロールしようとしていますか? ListItemまたはリスト全体を返します。あなたがより具体的にできる場合は、私はもっと助けてみることができます...

+0

私はlistviewの最初の行としてimageViewを配置する必要があると思うが、私はすでにそれを許可しないカスタム行レイアウトを持って、私は元の投稿にカスタムrow.xmlを追加しました。私は最善の選択肢は、行としてlistViewにimageViewを追加することだと思うが、私は現在のrow.xmlレイアウトでそれを行う方法を知らない。 – Meatje

関連する問題