【问题标题】:how to give margin to svg icon in android?如何为android中的svg图标留出余量?
【发布时间】:2018-10-15 08:43:41
【问题描述】:

我是 android 开发的新初学者,并尝试从搜索栏按钮内的 top 中提供边距 SVG google icon。我知道它的快速修复,但我已经尝试不受影响的保证金属性!

XML

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:drawableTop="@drawable/ic_search"
    android:textColor="#FFF"
    android:background="#3bbdfa"/>


<EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/button1"
    android:layout_alignParentLeft="true"
    android:ems="13"
    android:textColor="#CCC"
    android:hint="Search..."
    android:background="@null"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="15dp"
    android:layout_marginBottom="15dp" />

输出

see search-bar here

谁能解决?任何帮助表示赞赏。

【问题讨论】:

  • #Navjot 尝试给drawablepadding
  • 感谢您的评论先生,它没有工作没有任何改变!
  • 使用 ImageView 或 ImageButton 更好地完成此类工作

标签: android icons margin


【解决方案1】:

您可以使用 ImageView 而不是 Button 如this answer中所述, Center a drawable in a Button with background and no text

【讨论】:

    猜你喜欢
    • 2021-06-12
    • 1970-01-01
    • 2021-05-10
    • 1970-01-01
    • 2018-09-13
    • 2021-11-21
    • 2022-12-05
    • 2015-07-15
    • 1970-01-01
    相关资源
    最近更新 更多