2017-11-08 16 views
0

私は、ListViewとImageで構成されるレイアウトを持っています。
私はリストビュー(左上隅)の上にイメージを配置したいですが、アプリケーションを実行すると、リストビューのみが表示され、イメージはリストビューの後ろになります。 リストの最初の項目の代わりに画像を表示したい。
提案がありますか?ImageViewがListViewの上に表示されます

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:background="@android:color/background_light" 
    android:orientation="vertical"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="100"> 

    <FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

    <ImageView 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:background="@drawable/back" 
     android:id="@+id/back_button" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="10dp" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_gravity="left" 
     android:focusable="true" 
     /> 

    </FrameLayout> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    <ListView 

     android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:choiceMode="multipleChoice"> 

    </ListView> 

    </FrameLayout> 
</RelativeLayout> 

</LinearLayout> 
+0

Googleの「アンドロイドリストビューヘッダー」には、何百もの有用な結果が見つかります。このように:https://www.android-examples.com/add-set-header-to-listview-in-android-programmatically/ –

答えて

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:background="@android:color/background_light" 
android:orientation="vertical"> 

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

    <ImageView 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:background="@drawable/back" 
     android:id="@+id/back_button" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="10dp" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_gravity="left" 
     android:focusable="true" 
      /> 

    <ListView 
     android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:choiceMode="multipleChoice"> 

     </ListView> 

</LinearLayout> 

+0

ここにあなたの更新されたXMLコピーがあり、これを置き換えてexisting.Itは動作し、忘れることはありませんこの投稿を回答としてマークする:) –

+0

これは私がSaadに求めていることではありません。私はリストの最初の項目の代わりにイメージを表示したい。あなたは今私を助けることができますか? –

+0

oh buddy誤解をおかけして申し訳ありません...あなたはリストビューのヘッダーを検索する必要があります –

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:paddingBottom="@dimen/activity_vertical_margin" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingTop="@dimen/activity_vertical_margin" 
       android:background="@android:color/background_light" 
       android:orientation="vertical"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="100"> 

     <FrameLayout 
      android:id="@+id/frameLayoutImagevIew" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <ImageView 
       android:layout_width="30dp" 
       android:layout_height="30dp" 
       android:background="@drawable/back" 
       android:id="@+id/back_button" 
       android:layout_marginLeft="15dp" 
       android:layout_marginTop="10dp" 
       android:layout_alignParentTop="true" 
       android:layout_alignParentLeft="true" 
       android:layout_gravity="left" 
       android:focusable="true" 
       /> 

     </FrameLayout> 

     <FrameLayout 
      android:layout_below="@id/frameLayoutImagevIew" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
      <ListView 

       android:id="@android:id/list" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:choiceMode="multipleChoice"> 

      </ListView> 

     </FrameLayout> 
    </RelativeLayout> 



</LinearLayout> 
+0

フレームレイアウトを使用する必要はありませんが、私はあなたのコードレイアウトを変更しました –

0

ImageViewの中で標高値を設定してください:以下
は、レイアウトファイルです。例:android:elevation="5dp"。これはあなたの問題を解決するはずです。それが役に立てば幸い。

1

あなたはこれを試してみてください

listview.addHeaderView(view);// view which contains that image 

のように先頭に画像を追加するheaderviewを使用することができます。

関連する問題