2017-04-14 140 views
1

我希望我所有的相對佈局都圍繞一個圓形的相對佈局。Android Studio如何使相對佈局圍繞相對佈局?

這裏是我有什麼 My Design

上我怎樣才能使這項工作任何想法?

這是我的XML代碼,我沒有任何約束,因爲它們似乎沒有幫助。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 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" 
tools:context="com.example.alexei.roses.ImageDescription" 
tools:layout_editor_absoluteY="81dp" 
tools:layout_editor_absoluteX="0dp"> 

<RelativeLayout 
    android:id="@+id/s1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    tools:layout_editor_absoluteX="36dp" 
    tools:layout_editor_absoluteY="16dp"> 

    <TextView 
     android:id="@+id/geo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/circulargeo" 
     android:layout_centerHorizontal="true" 
     android:text="Geographic Origin" 
     android:textAlignment="center" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textStyle="bold" 
     tools:layout_editor_absoluteX="234dp" 
     tools:layout_editor_absoluteY="119dp" /> 

    <com.mikhaellopez.circularimageview.CircularImageView 
     android:id="@+id/circulargeo" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_centerHorizontal="true" 
     android:src="@drawable/geographic" 
     app:civ_border_color="@android:color/holo_blue_dark" 
     app:civ_border_width="4dp" 

     app:civ_shadow="true" 
     app:civ_shadow_color="@android:color/black" 
     app:civ_shadow_radius="10" 
     tools:layout_editor_absoluteX="248dp" 
     tools:layout_editor_absoluteY="16dp" /> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/s2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    tools:layout_editor_absoluteX="7dp" 
    tools:layout_editor_absoluteY="181dp"> 

    <TextView 
     android:id="@+id/sci" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/circularsci" 
     android:layout_centerHorizontal="true" 
     android:text="Scientific Name" 
     android:textAlignment="center" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textStyle="bold" 
     tools:layout_editor_absoluteX="0dp" 
     tools:layout_editor_absoluteY="0dp" /> 

    <com.mikhaellopez.circularimageview.CircularImageView 
     android:id="@+id/circularsci" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:src="@drawable/scientificname" 
     app:civ_border_color="@android:color/holo_blue_dark" 

     app:civ_border_width="4dp" 
     app:civ_shadow="true" 
     app:civ_shadow_color="@android:color/black" 
     app:civ_shadow_radius="10" 
     tools:layout_editor_absoluteX="28dp" 
     tools:layout_editor_absoluteY="327dp" /> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/s3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    tools:layout_editor_absoluteY="326dp" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent"> 

    <TextView 
     android:id="@+id/cha" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/circularcha" 
     android:layout_centerHorizontal="true" 
     android:text="Characteristics" 
     android:textAlignment="center" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textStyle="bold" 
     tools:layout_editor_absoluteX="234dp" 
     tools:layout_editor_absoluteY="119dp" /> 

    <com.mikhaellopez.circularimageview.CircularImageView 
     android:id="@+id/circularcha" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_centerHorizontal="true" 
     android:src="@drawable/characteristics" 
     app:civ_border_color="@android:color/holo_blue_dark" 
     app:civ_border_width="4dp" 

     app:civ_shadow="true" 
     app:civ_shadow_color="@android:color/black" 
     app:civ_shadow_radius="10" 
     tools:layout_editor_absoluteX="248dp" 
     tools:layout_editor_absoluteY="16dp" /> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/s4" 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    tools:layout_editor_absoluteY="181dp" 
    tools:layout_editor_absoluteX="278dp"> 

    <TextView 
     android:id="@+id/cul" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/circularcul" 
     android:layout_centerHorizontal="true" 
     android:text="Cultivation" 
     android:textAlignment="center" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textStyle="bold" 
     tools:layout_editor_absoluteX="-243dp" 
     tools:layout_editor_absoluteY="53dp" /> 

    <com.mikhaellopez.circularimageview.CircularImageView 
     android:id="@+id/circularcul" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_centerHorizontal="true" 
     android:src="@drawable/cultivation" 
     app:civ_border_color="@android:color/holo_blue_dark" 
     app:civ_border_width="4dp" 

     app:civ_shadow="true" 
     app:civ_shadow_color="@android:color/black" 
     app:civ_shadow_radius="10" 
     tools:layout_editor_absoluteX="248dp" 
     tools:layout_editor_absoluteY="16dp" /> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/s5" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    tools:layout_editor_absoluteX="253dp" 
    tools:layout_editor_absoluteY="16dp"> 

    <TextView 
     android:id="@+id/dis" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/circulardis" 
     android:layout_centerHorizontal="true" 
     android:text="Diseases and Pests" 
     android:textAlignment="center" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textStyle="bold" 
     tools:layout_editor_absoluteX="-243dp" 
     tools:layout_editor_absoluteY="53dp" /> 

    <com.mikhaellopez.circularimageview.CircularImageView 
     android:id="@+id/circulardis" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_centerHorizontal="true" 
     android:src="@drawable/diseases" 
     app:civ_border_color="@android:color/holo_blue_dark" 
     app:civ_border_width="4dp" 

     app:civ_shadow="true" 
     app:civ_shadow_color="@android:color/black" 
     app:civ_shadow_radius="10" 
     tools:layout_editor_absoluteX="248dp" 
     tools:layout_editor_absoluteY="16dp" /> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/mainImage" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    tools:layout_editor_absoluteY="142dp"> 

    <TextView 
     android:id="@+id/flowername" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/flowerimage" 
     android:layout_centerHorizontal="true" 
     android:text="TextView" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     tools:layout_editor_absoluteX="150dp" 
     tools:layout_editor_absoluteY="290dp" /> 

    <com.mikhaellopez.circularimageview.CircularImageView 
     android:id="@+id/flowerimage" 
     android:layout_width="150dp" 
     android:layout_height="150dp" 
     app:civ_border_color="@android:color/holo_blue_dark" 
     app:civ_border_width="4dp" 
     android:src="@drawable/amaryllis" 
     app:civ_shadow="true" 
     app:civ_shadow_color="@android:color/black" 
     app:civ_shadow_radius="10" 
     tools:layout_editor_absoluteX="117dp" 
     tools:layout_editor_absoluteY="135dp" /> 

</RelativeLayout> 

+0

也許你可以嘗試ConstraintLayout? –

回答

0

如果我到底要你想要的,如果你想ralative佈局要舍,我鼓勵你包裹在cardView相對佈局之後,您將設置cardCornerRadius

 <android.support.v7.widget.CardView 
      xmlns:card_view="http://schemas.android.com/apk/res-auto" 
      android:layout_width="wrap_content" 
      android:background="#FFFFFF" 
      android:layout_height="wrap_content" 
      card_view:cardCornerRadius="6dp" 
      card_view:contentPadding="4dp" 
      card_view:cardElevation="4dp" 
      card_view:cardMaxElevation="6dp" 
      card_view:cardBackgroundColor="#0077ff" 
      > 

       <RelativeLayout> 
       ... 
       </RelativeLayout> 
</android.support.v7.widget.CardView> 

你可以使用屬性來獲取你想要的東西

+0

我不希望相對佈局四捨五入。我想要一個圓形菜單。所有的小圖像都在平均分佈的大圖像周圍。 –