【问题标题】:How to enlarge the border around constraint layout in Android Studio Kotlin如何在 Android Studio Kotlin 中放大约束布局周围的边框
【发布时间】:2021-12-15 14:33:32
【问题描述】:

我在约束布局周围设置了一个边框,如图所示(浅绿色边框)。如何放大边框,如“RED”(附图)所示我尝试了填充命令,但没有做出任何改变。有人可以建议一个解决方案。谢谢!

<TextView
    android:id="@+id/viewBorder"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:background="@drawable/outside_shape"
    app:layout_constraintBottom_toBottomOf="@id/favoriteButton"
    app:layout_constraintEnd_toEndOf="@+id/favoriteButton"
    app:layout_constraintStart_toStartOf="@id/eventImage"
    app:layout_constraintTop_toTopOf="@id/eventPerson"  />

这是背景形状的代码

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <stroke
        android:width="1dp"
        android:color="#04C187" />

    <padding android:left="6dp"
        android:top="10dp"
        android:right="10dp"
        android:bottom="10dp"/>
</shape>

【问题讨论】:

    标签: android kotlin android-constraintlayout


    【解决方案1】:

    你的边框基本上是从背景形状来的,只是改变背景形状描边的宽度

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle" >
        <stroke
            android:width="5dp" <!-- Change the Width Here -->
            android:color="#04C187" />
    
        <padding android:left="6dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp"/>
    </shape>
    

    【讨论】:

    • 这只是让边框变厚,我喜欢保持相同的厚度,但向所有 4 个边的外侧偏移。
    • 我试图给一个 -value 来抵消,但这不起作用...任何想法
    猜你喜欢
    • 2021-12-23
    • 1970-01-01
    • 2019-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多