简体   繁体   中英

Child layout is out of bounds of the parent circle shape layout ANDROID

What i have now

现在

What i want to achieve

在此处输入图片说明

My XML:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:background="@drawable/circle_shape"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="140dp"
            android:layout_height="140dp"
            android:layout_centerInParent="true"
            android:orientation="horizontal"
            android:weightSum="2">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_marginRight="0.5dp"
                android:layout_weight="1"
                android:background="#000000"/>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_marginLeft="0.5dp"
                android:layout_weight="1"
                android:background="#BB69FF"/>

        </LinearLayout>
    </RelativeLayout>


My shape:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="2"
    android:useLevel="false">

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

</shape>

What do you think? Do you have any suggestions? I tried to use android:clipChildren on the parent layout, but the result is the same.

而不是相对父级布局,我使用的是此自定义视图组https://github.com/dmitry-zaitsev/CircleLayout/blob/master/src/ru/biovamp/widget/CircleLayout.java ,它看起来不错。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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