简体   繁体   English

围绕另一个CircleImageView的枢轴点旋转CircleImageView

[英]Rotate a CircleImageView around another CircleImageView's pivot point

I am working at a project in Xamarin. 我正在Xamarin的一个项目中工作。 Android where I use the CircleImageView NuGet package(which is just a library for RoundedImageViews ). 我在Android上使用CircleImageView NuGet包(这只是RoundedImageViews的库)。 I have a CircleImageView (call it civ1 ), and another one(call it civ2 ). 我有一个CircleImageView (称为civ1 ),和另一个(称为civ2 )。 I want to rotate civ2 around civ1 's center, at a certain angle. 我想围绕civ1的中心以特定角度rotate civ2 I know I can use 我知道我可以用

android:rotation="90" to rotate civ2 , but this will just rotate it around its own center which I don't want. android:rotation="90"旋转civ2 ,但这只会绕它自己的中心旋转,这是我不希望的。 So how could I rotate civ2 around civ1 's center point? 那么,如何围绕civ1的中心点rotate civ2

    <FrameLayout
        android:id="@+id/IDEQSVFL"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:background="@drawable/roundcornerslayout">
        <refractored.controls.CircleImageView
            android:id="@+id/civ1"
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_marginLeft="30dp"
            android:layout_gravity="left|center_vertical"
            android:src="@drawable/ME_RotatoryKnobMainImage" />
        <refractored.controls.CircleImageView
            android:id="@+id/civ2"
            android:layout_width="11dp"
            android:layout_height="11dp"
            android:layout_gravity="left|center_vertical"
            android:src="@drawable/ME_RotatoryKnobLed" />
</FrameLayout>

This is my code. 这是我的代码。

检查这张图片

android:rotation="90" to rotate civ2, but this will just rotate it around its own center which I don't want. android:rotation =“ 90”来旋转civ2,但这只会绕着它自己的中心旋转它,而我并不需要。 So how could I rotate civ2 around civ1's center point? 那么如何围绕civ1的中心点旋转civ2?

If you want the small circle to be in certain position that related to the circle 2, you just need to modify layout_marginLeft and layout_marginTop to change the position of the small circle: 如果您希望小圆圈处于与圆2相关的特定位置,则只需修改layout_marginLeftlayout_marginTop即可更改小圆圈的位置:

<FrameLayout
    android:id="@+id/IDEQSVFL"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="300dp"
    android:background="@drawable/snow">
    <refractored.controls.CircleImageView
        android:id="@+id/civ1"
        android:layout_width="110dp"
        android:layout_height="110dp"
        android:layout_marginLeft="30dp"
        android:layout_gravity="left|center_vertical"
        android:src="@drawable/timg2" />
    <refractored.controls.CircleImageView
        android:id="@+id/civ2"
        android:layout_width="11dp"
        android:layout_height="11dp"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="78dp"
        android:layout_gravity="top"
        android:src="@drawable/timg2" />
</FrameLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM