2016-05-25 6 views
0

私はImageViewすなわち表紙写真を持っています。もう1つのImageView、つまりプロフィール画像とテキストビュー、つまりCoverphoto内の名前。このカバー写真の下にリストビューがあります。レイアウト全体をスクロール可能にしたい、つまり、カバー写真のレイアウトもListviewでスクロールする必要があります。私はlist.addHeaderViewを試しましたが、どのようにprofile photoとcover.jpをlist.addheaderviewでマージするのですか?ListViewを使用したスクロール可能なImageView

+0

nestedscrollview内でlistviewを使用します。 –

+0

あなたは詳しく説明できますか? –

+0

http://ivankocijan.xyz/android-nestedscrollview/ –

答えて

0

すべて(表紙写真、プロフィール写真、名前など)を1つのレイアウト(例:LinearLayout | RelativeLayout)に入れてからインフレし、Listviewに追加します。あなたのコードは次のようなものかもしれ

View profielView = LayoutInflater.from(getActivity()).inflate(R.layout.view_your_profile, mListView, false); 
mListView.addHeaderView(profileView); 

あなたview_your_profileは次のようなものです:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layout_profile_header_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <!-- cover photo --> 
    <ImageView 
     android:id="@+id/image_profile_cover" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/ic_launcher" 
     android:scaleType="centerCrop" /> 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:orientation="horizontal"> 
      <!-- username --> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_marginRight="8dp" 
       android:text="@string/icon_chevron_left" 
       android:textColor="@color/white_transparent_30" /> 

      <!-- profile photo --> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:gravity="center"/> 

     </LinearLayout> 

</RelativeLayout> 

より良い方法は、あなたが良いチュートリアルを見つけることができるさまざまなビュータイプでRecyclerViewを使用してもありますhere

0

あなたのカバー写真のためにRelativeLayoutを作成し、その中にプロフィール画像とtextviewをheader.xmlという名前のファイルに入れる必要があります。

あなたはこれらの質問を参照することができます。

Android, ImageView over ImageView

Adding text to ImageView in Android

だから、あなたのheader.xmlを行った後、あなたのカバー写真、プロフィール画像、テキストを使用してリストビューに追加することができますリストビューをスクロールするとスクロールされます。

関連する問題