kotlin 无法最小化Neumorphism布局中两个相邻按钮之间差距

uplii1fm  于 2023-08-07  发布在  Kotlin
关注(0)|答案(1)|浏览(107)

我目前正在开发一个移动的应用程序,我已经使用com.github.fornewid:neumorphism:0.3.0库实现了Neumorphism设计。在我的布局中,我要求显示两个相邻的按钮,它们之间没有任何可见的间隙。但是,我正面临着在删除或最大限度地减少这些按钮之间的差距的困难。
为了更好地理解这个问题,我附上了布局x1c 0d1x的屏幕截图
此外,以下是布局相关部分的XML代码片段:

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="8dp">

    <soup.neumorphism.NeumorphCardView
        android:id="@+id/start_timer"
        android:layout_width="@dimen/_100sdp"
        android:layout_height="@dimen/_60sdp"
        android:clickable="true"
        android:padding="@dimen/_18sdp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:neumorph_shadowColorDark="@color/dark_shadow_dark"
        app:neumorph_shadowColorLight="@color/light_shadow_dark"
        app:neumorph_shapeAppearance="@style/NeumorphismTimerShape"
        app:neumorph_shapeType="flat"
        app:neumorph_strokeColor="@color/black"
        app:neumorph_strokeWidth="1dp">

        <ImageView
            android:layout_gravity="center"
            android:id="@+id/start_timer_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/timer_icon" />

        <TextView
            android:id="@+id/timer_countdown_text"
            android:layout_width="wrap_content"
            android:layout_height="34dp"
            android:layout_gravity="center"
            android:text="@string/_00_00_00"
            android:textColor="@color/leaveGreen"
            android:textSize="18sp"
            android:textStyle="bold"
            android:visibility="invisible" />

    </soup.neumorphism.NeumorphCardView>

    <soup.neumorphism.NeumorphImageView
        android:id="@+id/cancel_timer"
        android:layout_width="@dimen/_60sdp"
        android:layout_height="@dimen/_60sdp"
        android:clickable="true"
        android:padding="@dimen/_18sdp"
        android:src="@drawable/timer_off_icon"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:neumorph_shadowColorDark="@color/dark_shadow_dark"
        app:neumorph_shadowColorLight="@color/light_shadow_dark"
        app:neumorph_shapeAppearance="@style/NeumorphismTimerOffShape"
        app:neumorph_shapeType="flat"
        app:neumorph_strokeColor="@color/black"
        app:neumorph_strokeWidth="1dp" />

</LinearLayout>

字符串
此外,我为按钮中使用的Neumorphism形状定义了以下样式:

<style name="NeumorphismTimerShape">
    <item name="neumorph_cornerSizeBottomLeft">@dimen/_115sdp</item>
    <item name="neumorph_cornerSizeTopLeft">@dimen/_115sdp</item>
</style>

<style name="NeumorphismTimerOffShape">
    <item name="neumorph_cornerSizeBottomRight">@dimen/_115sdp</item>
    <item name="neumorph_cornerSizeTopRight">@dimen/_115sdp</item>
</style>


有人能指导我如何实现所需的布局,在Neumorphism设计中相邻按钮之间没有可见的间隙吗?如有任何建议或替代办法,将不胜感激。
提前感谢您的帮助!

91zkwejq

91zkwejq1#

试试这个布局,你用NeumorphCardView Package 所有东西,里面的东西会用LinearLayout水平对齐:

<soup.neumorphism.NeumorphCardView
    android:id="@+id/start_timer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:padding="@dimen/_18sdp"
    android:layout_marginTop="8dp"
    app:neumorph_shadowColorDark="@color/dark_shadow_dark"
    app:neumorph_shadowColorLight="@color/light_shadow_dark"
    app:neumorph_shapeAppearance="@style/NeumorphismTimerShape"
    app:neumorph_shapeType="flat"
    app:neumorph_strokeColor="@color/black"
    app:neumorph_strokeWidth="1dp">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <LinearLayout
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:orientation="vertical">
        
           <ImageView
               android:layout_gravity="center"
               android:id="@+id/start_timer_icon"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@drawable/timer_icon" />

           <TextView
               android:id="@+id/timer_countdown_text"
               android:layout_width="wrap_content"
               android:layout_height="34dp"
               android:layout_gravity="center"
               android:text="@string/_00_00_00"
               android:textColor="@color/leaveGreen"
               android:textSize="18sp"
               android:textStyle="bold"
               android:visibility="invisible" />
        </LinearLayout>
    
    <ImageView
        android:id="@+id/cancel_timer"
        android:layout_width="@dimen/_60sdp"
        android:layout_height="@dimen/_60sdp"
        android:clickable="true"
        android:padding="@dimen/_18sdp"
        android:src="@drawable/timer_off_icon"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    </LinearLayout>

</soup.neumorphism.NeumorphCardView>

字符串

相关问题