2017-07-05 5 views
1

おはよう、Androidスタジオアプリサークルプロフィール画像

私のアプリでやってみたいと思っているのは、プロフィール画像を円形にすることです。これは現在、 'マッチする親'フォームにあり、画面全体を塗りつぶし、whatsappタイプの円形イメージを表示したいと考えています。これを行う最善の方法は何ですか?

これが私の現在のxmlです:CircleImageViewであなたのImageViewのを置き換え

`<?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" 
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" 
tools:context="com.nalexanderdev.runcommunity.activities.ProfileActivity"> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:text="Profile" 
    android:id="@+id/textView3" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:textStyle="bold" 
    android:gravity="center" /> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textPersonName" 
    android:ems="10" 
    android:id="@+id/nameField" 
    android:hint="Name" 
    android:layout_above="@+id/emailField" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" /> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textEmailAddress" 
    android:ems="10" 
    android:id="@+id/emailField" 
    android:hint="[email protected]" 
    android:layout_above="@+id/cancelBtn" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Cancel" 
    android:id="@+id/cancelBtn" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentStart="true" /> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Update" 
    android:id="@+id/updateBtn" 
    android:layout_alignParentBottom="true" 
    android:layout_alignEnd="@+id/emailField" /> 

<Button 
    android:id="@+id/selectImage" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/textView3" 
    android:layout_centerHorizontal="true" 
    android:text="Select Image From Gallery" /> 

<ImageView 
    android:id="@+id/imageView2" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/selectImage" 
    android:layout_centerHorizontal="true" 
    app:srcCompat="@color/common_google_signin_btn_text_light_disabled" /> 
</RelativeLayout>` 
+0

これを達成する方法には多くのリソースがあります。 https://www.youtube.com/results?search_query=circular+imageview+androidまたはhttps://www.google.pl/search?q=circular+image+view+android – lidkxx

答えて

0

<de.hdodenhof.circleimageview.CircleImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_below="@+id/selectImage" 
      app:srcCompat="@color/common_google_signin_btn_text_light_disabled" 
      android:id="@+id/imageView2" 
      app:civ_border_color="@color/colorPrimary" 
      app:civ_border_width="1dp 
       /> 

そして 'de.hdodenhof 2.1.0:circleimageview' コンパイルを追加するには、Gradleの依存関係に。