我是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