2012-12-04 4 views
0

다음은 달성하려는 레이아웃입니다. 그래서 센터링하고 오른쪽 정렬을 왼쪽으로하는 방법을 알고 있지만, RelativeLayout과 결합하면 원하는 결과를 얻지 못하고 있습니다. 마진/패딩이 추가되지 않으면 TextViews가 모두 남습니다. 나는 Left-Right-Center에 맞는 수식을 가지고 있지만이 텍스트 옆에 텍스트를 넣고 싶을 때는 효과가 없습니다. 당신은 각각의 왼쪽에 ImageView 필요하지 않습니다동시에 센터링 및 상대 레이아웃을 제공하는 방법

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

답변

0

: 여기

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

내 레이아웃입니다 (그것은 단지는 왼쪽 길을 통해 이었기 때문에 마진을 많이 필요로 하나의 텍스트를 포함 TextView, 단순히 TextView의 왼쪽에 왼쪽 coumpound 드로어 블을 설정하고 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> 
+0

클릭해야합니다. 이미지 .... – user1847544

+0

클릭 할 수있는 전체 TextView를 설정할 수 있습니다. 다른 솔루션 작업도 마찬가지로 더 많은 리소스를 소비합니다. – znat

0

당신은 말아야 다른 상대 레이아웃에서 이들을 중첩하여 하나의 큰 선형 레이아웃으로 배치하십시오.

<LinearLayout.....> 

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

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

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

</LinearLayout> 
관련 문제