用于在圆圈中表示图像的布局

时间:2014-05-06 12:31:59

标签: android android-layout imageview

我需要为下面图片中的不同表情设置不同的ImageView。我应该使用哪种布局来实现这一目标。

two muppets http://imageshack.com/a/img836/5170/lwcg.png

提前致谢!

3 个答案:

答案 0 :(得分:0)

我认为您最好的选择是创建自己的视图并在onDraw方法中执行此操作。

答案 1 :(得分:0)

这类似于圆形布局。检查here以获取教程。

还有library。检查一下。

答案 2 :(得分:0)

您可以使用此布局。 for circle_effect.xml

<gradient
    android:angle="270"
    android:endColor="#ffffff"
    android:startColor="#ffffff" />

<stroke
    android:width="10dp"
    android:color="#cdcdcd" /></shape>

主要

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_marginBottom="20dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="20dp"
    android:background="@drawable/circle_effect"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_centerInParent="true"
            android:background="@drawable/man" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="-10dp" >

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="60dp"
            android:background="@drawable/man" />

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_alignParentRight="true"
            android:layout_marginRight="60dp"
            android:background="@drawable/man" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp" >

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="18dp"
            android:background="@drawable/man" />

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_alignParentRight="true"
            android:layout_marginRight="18dp"
            android:background="@drawable/man" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp" >

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_alignParentLeft="true"
            android:background="@drawable/man" />

        <ImageView
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_alignParentRight="true"
            android:background="@drawable/man" />
    </RelativeLayout>
</LinearLayout>

我只创造了一半。

enter image description here