Java 像子弹一样在textView之前添加矢量图标-Android编程
在最新的Android Studio中提供了新的矢量资源,我想在文本视图之前添加一个图标,比如图标/项目符号 在我的文本视图之前使用非常小的imageView并添加另一个图像看起来很奇怪。我尝试了Java 像子弹一样在textView之前添加矢量图标-Android编程,java,android,android-icons,Java,Android,Android Icons,在最新的Android Studio中提供了新的矢量资源,我想在文本视图之前添加一个图标,比如图标/项目符号 在我的文本视图之前使用非常小的imageView并添加另一个图像看起来很奇怪。我尝试了android:icon,但没有成功 我基本上想使用矢量图标,比如字体图标。 我想在网页设计中为:Title-提供Java等价物。我已经在drawable文件夹中将ic_star.xml作为矢量资源提供,如何将此布局作为textView的前缀?您可以简单地将LinearLayout与android一起使
android:icon
,但没有成功
我基本上想使用矢量图标,比如字体图标。
我想在网页设计中为:
Title
-提供Java等价物。我已经在drawable文件夹中将ic_star.xml
作为矢量资源提供,如何将此布局作为textView的前缀?您可以简单地将LinearLayout与android一起使用:orientation=“horizontal”
查找文本视图复合绘图。这就是你想要的。谢谢android:drawableLeft=“@drawable/ic_star”
和android:drawablePadding=“10dp”
正是我需要的!!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/ic_star" />
<TextView
android:id="@+id/TextAct1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="This "
android:textSize="20dp" />
</LinearLayout>