我在FIGMA中设计了一个UI,如下所示
当我在android演播室尝试同样的时候,它看起来不太好。下面是我正在使用的代码
<LinearLayout
android:id="@+id/dark"
android:layout_width="364dp"
android:layout_height="46dp"
android:layout_marginTop="36dp"
android:background="@drawable/bg_layout"
android:elevation="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/night"
android:layout_gravity="center_vertical"/>
</LinearLayout>
UI如下所示
如何实现我使用Figma创建的设计?提前谢谢你。
发布于 2022-04-07 06:32:53
为了实现该设计,资料卡视图为您提供了大部分功能。
标高:app:cardElevation="dp"
:
app:strokeWidth="dp"
指定宽度的app:strokeColor="@color/"
app:cardCornerRadius="dp"
.比如:
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="@dimen/corner_radius_8dp"
app:cardElevation="@dimen/elevation_4dp"
app:cardUseCompatPadding="true"
app:strokeColor="?attr/colorPrimary"
app:strokeWidth="@dimen/stroke_width">
<!--Content goes here-->
</com.google.android.material.card.MaterialCardView>
发布于 2022-04-07 05:47:43
在Android中创建这种类型的UI有多种方法。
我希望你能理解我想说的。
谢谢。
https://stackoverflow.com/questions/71776880
复制相似问题