2016-11-06 5 views
0

私はイベントを持っているプロジェクトに取り組んでいます。ユーザーはイベントを見て、出席するかどうかを選択します。問題は..私は人の添付された画像に表示される丸い画像のセクションを作る必要があります誰がこのイベントに参加してイベントビューアに表示されますか?丸みを帯びた画像のセクションを作る方法アンドロイド?

どうすればいいですか?

Rounded Images Picture

答えて

0

あなたは動的レイアウトでビューを追加することができます。あなたがのLinearLayoutにビューを追加するコードでここ

は your_activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 

    <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/layout_list_view" 
       android:gravity="center" 
       android:layout_marginLeft="20dp"  
       android:orientation="horizontal"> 
       </LinearLayout> 

       </RelativeLayout> 

にそれらがイベントに参加しているユーザーのこのごCircleImageViewをlayout_list_view。これは:)

を助ける
add_view.xml

  <?xml version="1.0" encoding="utf-8"?> 
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:app="http://schemas.android.com/apk/res-auto" 
       android:layout_width="match_parent" 
       android:layout_height="60dp"> 
      <com.leafwearables.saferkids.customViews.AppCompatCircleImageView 
        android:id="@+id/imageView" 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:layout_centerVertical="true" 
        android:layout_marginLeft="-20dp" 
        app:civ_border_color="@color/white" 
        app:civ_border_width="1dp" 
        app:srcCompat="@drawable/temp" /> 

        </RelativeLayout> 

あなたのビューのViewHolderを作成

  public class UserVH extends RecyclerView.ViewHolder { 

      public UserVH(View inflate, int ind) { 
        super(inflate); 
        index = ind; 
        baseView = itemView; 
        initialize(itemView); 
       } 

       private void initialize(View itemView) { 
        imageView = (AppCompatCircleImageView) itemView.findViewById(R.id.imageView); 

       } 


       public int getIndex() { 
        return index; 
       } 

       public View getBaseView() { 
        return baseView; 
       } 

      } 

YourActivty.class

  private void addUsersView() { 

         LinearLayout user_list_view = (LinearLayout) findViewById(R.id.layout_list_view); 
         final UserVH[] views = new UserVH[userList.size()]; 
         for (int i = 0; i < views.length; i++) { 
         views[i] = new UserVH(LayoutInflater.from(this).inflate(R.layout.add_view, null), i); 
            try { 
             File profileFile = new File(getProfileDir(this), child.getDeviceId()); 
             if (profileFile.exists()) { 
             Bitmap bitmap = BitmapFactory.decodeFile(profileFile.getPath()); 
              views[i].imageView.setImageBitmap(bitmap); 
             } 
            } catch (Exception e) { 
             e.printStackTrace(); 
            } 
            user_list_view.addView(views[i].getBaseView(), -1, 60); 

            } 

         } 

          public File getProfileDir(Context context) { 
           File fileProfile = new File(context.getFilesDir(), "USERS"); 
           fileProfile.mkdir(); 
           return fileProfile; 
          } 

・ホープ

関連する問題