SQLite、独自の ContentProvider、およびローダーに関する Lars Vogel のチュートリアルでは、ToDo 項目のリストに次のレイアウトを使用しています ( http://www.vogella.com/articles/AndroidSQLite/article.html#todo_layout、todo_row.xmlレイアウト ファイルを確認してください)。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/icon"
android:layout_width="30dp"
android:layout_height="24dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:src="@drawable/reminder" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:lines="1"
android:text="@+id/TextView01"
android:textSize="24dp"
>
</TextView>
</LinearLayout>
ここまでは順調ですね。それはうまく機能します。ImageViewAndroid 開発者ツール (Eclipse) は、 を のdrawable属性に置き換えることを提案していますTextView。次のレイアウト定義を試しました:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="4dp"
android:drawablePadding="8dp"
android:drawableStart="@drawable/reminder"
android:lines="1"
android:text="@+id/TextView01"
android:textSize="24sp"
>
</TextView>
</LinearLayout>
つまり、drawableStartの代わりに が使用されましたImageView。関連android:layout_marginLeftし、android:drawablePadding正常に動作するようです。
ただし、drawable のサイズがわかるかどうかはわかりません。このImageViewソリューションでは、android:layout_width/height属性を使用して、必要なアイコンのサイズを伝えました。TextView-only ソリューションと に似たものはありandroid:drawable...ますか?
ありがとう、ペトル