現在、プロジェクトの小さな更新に取り組んでいますが、リストビューのRelative_Layoutとfill_parentに問題があります。デフォルトのダイヤラのコールログの仕切りのように、各行の2つのセクションの間に仕切りを挿入しようとしています。Androidのソースコードをチェックして、どのように実行されたかを確認しましたが、ソリューションを複製するときに問題が発生しました。
まず、行アイテムのレイアウトを次に示します。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dip"
android:layout_height="fill_parent"
android:maxHeight="64dip"
android:minHeight="?android:attr/listPreferredItemHeight">
<ImageView android:id="@+id/infoimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/info_icon_big"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
<View android:id="@+id/divider"
android:background="@drawable/divider_vertical_dark"
android:layout_marginLeft="11dip"
android:layout_toLeftOf="@+id/infoimage"
android:layout_width="1px"
android:layout_height="fill_parent"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_marginRight="4dip"/>
<TextView android:id="@+id/TextView01"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/ImageView01"
android:layout_toLeftOf="@+id/divider"
android:gravity="left|center_vertical"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"/>
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@drawable/bborder"
android:layout_centerVertical="true"/>
</RelativeLayout>
私が直面している問題は、各行にさまざまな高さのサムネイル(ImageView01)があることです。RelativeLayoutのlayout_heightプロパティをfill_parentに設定すると、仕切りは行を埋めるために垂直方向に拡大縮小されません(1pxのドットのままです)。layout_heightを"?android:attr / listPreferredItemHeight"に設定すると、仕切りは行を埋めますが、サムネイルは縮小します。アダプタのgetView()メソッドでデバッグを行いましたが、行が適切な高さになると、仕切りの高さが適切に設定されていないようです。
getView()メソッドの一部を次に示します。
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
view = inflater.inflate(R.layout.tag_list_item, parent, false);
}
メソッドの残りの部分では、行に適切なテキストと画像を設定するだけです。
また、アダプターのコンストラクターでインフレーターオブジェクトを次のように作成します。inflater = LayoutInflater.from(context);
私は何か重要なものが欠けていますか?または、fill_parentは動的な高さでは機能しませんか?