2016-07-29 5 views
0

Androidスタジオ(Whats-appのもののような)の正方形ではなく、丸みのある形状のImage-viewを作成しようとしています。Androidスタジオで丸みを帯びた(丸で囲んだ)ImageViewボックスを作成するにはどうすればよいですか?

これは私のxmlファイルである

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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="@drawable/background" 
    tools:context="com.example.ska89.xxxxxx.MainActivity"> 

    <ImageView 
     android:layout_width="150dp" 
     android:layout_height="150dp" 
     android:id="@+id/imageView2" 
     android:src="@drawable/logo" 
     android:layout_marginTop="64dp" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:adjustViewBounds="false" 
     android:clickable="false" /> 
</RelativeLayout> 

ありがとうございます。

+5

見て[これ](http://stackoverflow.com/questions/22105775/imageview-in-circular-through-xml)、それはあなたを助けるためにうまくいきます –

+0

これを試すhttp://stackoverflow.com/a/16208548/5612089 –

答えて

1

この

<ImageView 
    android:layout_width="150dp" 
    android:layout_height="150dp" 
    android:id="@+id/imageView2" 
    android:src="@drawable/logo" 
    android:layout_marginTop="64dp" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:adjustViewBounds="false" 
    android:background="@drawable/circle_shape" 
    android:clickable="false" /> 
のような背景のものとしてあなたImageViewの中で、このcircle_shape.xmlを使用し、この

<?xml version="1.0" encoding="utf-8"?> 
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval"> 

    <solid 
     android:color="@color/colorRound"/> 

    <size 
     android:width="50dp" 
     android:height="50dp"/> 
</shape> 

のようなものを自分の引き出し可能フォルダに例えばcircle_shape.xml xmlファイルを作成し、次のコードを記述

関連する問題