0

実際のビュー

現時点での私の見解はこうです。

ご覧のとおり、すべてのアイコンが左端まで揃っているわけではありません。赤い線が私の目標です。左端まで行っても問題ありません。後で で解けるからmarginLeftです。

これは私の XML コード ( layout/listview_style_listview.xml ) です。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/BackGroundColor"
    android:orientation="vertical"
    android:scaleType="center" >

    <LinearLayout
        android:id="@+id/titleLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:layout_marginBottom="2dp"
        android:layout_marginLeft="7dp"
        android:layout_marginRight="7dp"
        android:background="@color/BackGroundColor"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/sectionTitle"
            style="@style/sectionTitle"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="left"
            android:text="(blank)" />

        <Button
            android:id="@+id/sectionInfoButton"
            android:layout_width="33dp"
            android:layout_height="33dp"
            android:layout_gravity="right"
            android:layout_marginLeft="3dp"
            android:layout_weight="0"
            android:background="@drawable/infoicon" />

        <Button
            android:id="@+id/sectionInfoButton"
            android:layout_width="33dp"
            android:layout_height="33dp"
            android:layout_gravity="right"
            android:layout_marginLeft="3dp"
            android:layout_weight="0"
            android:background="@drawable/filtericon" />

        <Button
            android:id="@+id/sectionOptionsButton"
            android:layout_width="33dp"
            android:layout_height="33dp"
            android:layout_gravity="right"
            android:layout_marginLeft="3dp"
            android:layout_weight="0"
            android:background="@drawable/menuicontop2" />

        <Button
            android:id="@+id/addCatButton"
            android:layout_width="33dp"
            android:layout_height="33dp"
            android:layout_gravity="right"
            android:layout_marginLeft="3dp"
            android:layout_weight="0"
            android:background="@drawable/effect_button_add_cat_click" />
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="3dp"
        android:layout_marginBottom="0dp"
        android:layout_marginLeft="0dip"
        android:layout_marginRight="0dip"
        android:background="@color/blueOceanStroke" />

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@color/BlueOcean"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/listview_style_list_selector"
        android:paddingBottom="1dp" />

</LinearLayout>

これは私の XML コードです ( layout/listview_style_row.xml )

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minHeight="35dp" >

    <ImageView
        android:id="@+id/catThumbnail"
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/bank1" />

    <TextView
        android:id="@+id/sectionTitle"
        style="@style/title"
        android:layout_width="97dp"
        android:layout_height="32dp"
        android:layout_alignBottom="@+id/catThumbnail"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_marginLeft="66dp"
        android:gravity="center_vertical"
        android:text="Title Text"
        android:textColor="@color/listsTextColor"
        android:textSize="15sp"
        android:textStyle="normal"
        android:typeface="normal" />

    <ImageView
        android:layout_width="25dip"
        android:layout_height="32dp"
        android:layout_alignBottom="@+id/sectionTitle"
        android:layout_alignParentRight="true"
        android:gravity="center_vertical"
        android:src="@drawable/arrow" />

</RelativeLayout>

PS: スクリーンショットの右側に矢印アイコンを追加したため、画像に表示されていませんが、重要ではないと思います。

4

3 に答える 3

0

他の誰かが述べたように、ImageView を削除して、TextView が赤い線と一致するかどうかを確認します。そうである場合、ImageView にはいくつかの問題があります。そうでない場合は、別の問題です。また、ImageView の高さと幅が同じではない場合があり、32 dp に設定することで行っているスケーリングで問題が発生する可能性があります。参照: ImageView の周りの不要なパディング

ImageView を FrameLayout でラップする方が簡単な場合があります。このようなもの:

<FrameLayout>
    android:layout_width="32dp"
    android:layout_height="32dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" >

    <ImageView
        android:id="@+id/catThumbnail"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/bank1" />

</FrameLayout>

または、それがうまくいかない場合は、画像ビューやフレーム レイアウトの幅と高さを wrap_content に設定してみてください。また、その画像が 9 パッチの場合は、他の原因が考えられます。

于 2013-08-01T13:50:31.127 に答える