0

これが私が達成しようとしているレイアウトです。したがって、中央揃えと左右揃えの方法は知っていますが、RelativeLayout と組み合わせると、望ましい結果が得られません。マージン/パディングが追加されない限り、TextViews はすべて左に移動します。Left-Right-Center の正しい式がありますが、これらの横にテキストを配置したい場合は機能しません。

 <ImageView> <TextView>   <ImageView><TextView>     <ImageView><TextView>

これが私のレイアウトです(左側にあるため、多くの余白が必要なテキストが1つだけ含まれています:

  <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
    <ImageView android:id="@+id/reply_button" android:src="@drawable/icons_reply"
        android:layout_width="60dp" andorid_layout_alignParentLeft="true" android:layout_height="wrap_content" android:paddingRight="5dp"/>
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Reply"
     android:layout_alignLeft="@+id/reply_button" android:layout_marginLeft="50dip" android:textSize="12sp"/>
    <ImageView android:id="@+id/resend_button" android:src="@drawable/icons_resend"
        android:layout_width="60dp" android:layout_height="wrap_content" android:layout_centerInParent="true" android:paddingRight="5dp"/>
    <ImageView android:id="@+id/select_button"  android:focusableInTouchMode="false" android:focusable="false" android:layout_alignParentRight="true" android:src="@drawable/select_icon"
        android:layout_width="60dp" android:layout_height="wrap_content" android:paddingRight="5dp"/>
    </RelativeLayout>
4

2 に答える 2

0

ImageViewそれぞれの左側に は必要ありませんTextView。単純に左側の化合物ドローアブルをあなたの左側に設定し、TextViewそれらを a に配置しLinearLayoutます。

<LinearLayout
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content"
    <TextView
    ...
    android:drawableLeft="@drawable/yourimage"
    android:drawablePadding="3dp" //optional, if you want some padding
    android:gravity="center_vertical" // to center vertically the text and drawable
    weight="1" // use this in a LinearLayout so they will be 
               // uniformly distributed over the space
    ...
    />
</LinearLayout>
于 2012-12-04T03:09:35.690 に答える
0

これらを他の相対レイアウトにネストして、1 つの大きな線形レイアウトに配置する必要があります。

<LinearLayout.....>

<RelativeLayout
android:weight=1>
<image>
<Text>
</RelativeLayout>

<RelativeLayout
android:weight=1
>
<image>
<Text>
</RelativeLayout>

<RelativeLayout
android:weight=1>
<image>
<Text>
</RelativeLayout>

</LinearLayout>
于 2012-12-04T03:11:51.697 に答える