gpt4 book ai didi

android - 如何弯曲布局?

转载 作者:行者123 更新时间:2023-11-29 19:01:30 24 4
gpt4 key购买 nike

我想复制类似 this 的设计我尝试创建自定义布局来制作弧形,但图像不会落后于布局。 here它看起来像什么。任何其他想法我怎样才能实现设计?

这是我的 arc.xml 代码

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00885588"/>
<stroke android:width="1dp"
android:color="#000000"
/>
<corners
android:bottomRightRadius="100dp"
android:bottomLeftRadius="100dp"/>
</shape>
</item>
</layer-list>

layout_main.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"
android:gravity="center_horizontal"
android:orientation="vertical">


<android.support.constraint.ConstraintLayout
android:layout_width="395dp"
android:layout_height="182dp"
android:background="@drawable/arc"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/imageView4"
android:layout_width="173dp"
android:layout_height="179dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@mipmap/ic_launcher_round" />

</android.support.constraint.ConstraintLayout>


</android.support.constraint.ConstraintLayout>

最佳答案

用下面显示的代码制作一个drawablexml文件

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorPrimary"/>
<item android:top="-250dp"
android:bottom="350dp"
android:left="-200dp"
android:right="-200dp">
<rotate
android:fromDegrees="-0"
android:pivotX="0%"
android:pivotY="100%">
<shape
android:shape="oval">
<solid
android:color="?android:colorBackground"
tools:targetApi="lollipop" />
</shape>
</rotate>
</item>

并将其用作布局的背景,它将解决您的问题

关于android - 如何弯曲布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48943393/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com