我是Android新手。将图片与Android中的图片对齐
如何使用相对布局将textView与ImageView的中心对齐?
我尝试下面的代码:
<RelativeLayout 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"
tools:context="${relativePackage}.${activityClass}" >
<ImageView
android:id="@+id/item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxHeight="15dp"
android:maxWidth="15dp"
android:src="@drawable/icon" />
<TextView
android:id="@+id/item_counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/item_icon"
android:text="Counter" />
</RelativeLayout>
但文字不与画面的中心对齐。
谢谢!
最好的方法是将图像作为复合可绘制添加到TextView中,而不是使用ImageView。即:'android:drawableLeft =“@ drawable/icon”'。 – 2014-12-05 08:14:32