像子弹一样在 textView 之前添加矢量图标 - Android 编程
Adding vector icons before textView like a bullet - Android Programming
有了最新 Android Studio 中可用的新矢量资源,我想在 textView 之前添加一个图标,例如 icon/bullet。
在我的 textView 之前使用非常小的 imageView 并添加另一个图像似乎很奇怪。我试了 android:icon
没用。
我基本上想使用矢量图标,例如超棒的字体图标。
我想要 Java 等效于: <i class = "fa fa-star"></i> Title
- 在网页设计中。我已将 ic_star.xml
作为可绘制文件夹中的矢量资源提供,如何将此布局作为 textView 的前缀包含在内?
您可以简单地使用 LinearLayout 和 android:orientation="horizontal"
<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>
查找 TextView 复合绘图。这就是你想要的。
有了最新 Android Studio 中可用的新矢量资源,我想在 textView 之前添加一个图标,例如 icon/bullet。
在我的 textView 之前使用非常小的 imageView 并添加另一个图像似乎很奇怪。我试了 android:icon
没用。
我基本上想使用矢量图标,例如超棒的字体图标。
我想要 Java 等效于: <i class = "fa fa-star"></i> Title
- 在网页设计中。我已将 ic_star.xml
作为可绘制文件夹中的矢量资源提供,如何将此布局作为 textView 的前缀包含在内?
您可以简单地使用 LinearLayout 和 android:orientation="horizontal"
<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>
查找 TextView 复合绘图。这就是你想要的。