【问题标题】:Android Stroke Shape Drawable Left for TextViewAndroid Stroke Shape Drawable Left for TextView
【发布时间】:2018-08-29 21:06:53
【问题描述】:

以下是我的可绘制 xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
    android:width="1dp"
    android:color="@color/button_blue" />

下面是textView xml

                    <TextView
                    android:id="@+id/tvOrigin"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="5dp"
                    android:drawableLeft="@drawable/circle_cab"
                    android:drawablePadding="16dp"
                    android:drawableTint="@color/deal_disc_bg"
                    android:ellipsize="end"
                    android:lineSpacingExtra="2sp"
                    android:maxLines="1"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp"
                    android:text="ksjkdjksjkdjkj"
                    android:textSize="14sp" />

我发现drawable没有出现在textview的左侧

然后我在drawable xml中添加了以下内容

   <size
    android:width="10dp"
    android:height="10dp" />

添加这条线后,我可以在左侧绘制,但绘制的是实心圆而不是描边

知道如何仅通过 XML 将笔画圈作为可绘制的左侧添加到 textview 中,而不是实用的。

【问题讨论】:

  • 请同时添加相关的输出屏幕截图以更清晰。
  • 如果尺寸是 2x2 dp,你期望什么?
  • 也试过其他尺寸
  • 例如尝试测试笔画宽度 2px 和大小 8px 和 8px
  • 对我来说,圈子不是满的,它是空心的,带有您指定的&lt;size&gt; 属性。

标签: android textview android-drawable


【解决方案1】:

我认为所有的圆圈都是笔画。我的意思是,您的笔画宽度正是大小(考虑左笔画 1 和右笔画 1)来修复它尝试增加大小或减小鹳的宽度。

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
    android:width="0.5dp"
    android:color="@color/button_blue" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-13
    • 2022-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多