2016-09-15 5 views
0

채팅 거품을위한 간단한 레이아웃이 있습니다. 내가 이미지를 설정할 때 원치 않는 여백이있는 채팅 거품의 이미지

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/bubble_layout_chat_parent" 
android:orientation="vertical" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/bubble_layout_chat" 
    android:orientation="vertical" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <ImageView 
     android:id="@+id/message_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <TextView 
     android:id="@+id/message_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="@android:color/primary_text_light" 
     android:layout_gravity="top" 
     android:textSize="16sp"/> 

    <TextView 
     android:id="@+id/message_time" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#999" 
     android:textSize="10sp" 
     android:textStyle="italic" 
     android:textColorHint="@color/grey" 
     android:layout_gravity="bottom|end"/> 
</LinearLayout> 

는하지만, 원치 않는 여백 이미지 위와 아래에 둡니다.

enter image description here

어떻게 마진을 제거하고 이미지에 맞게 거품을 만들 수 있습니까?

: 귀하의 이미지 뷰에 대한 대한

+0

당신은 시도 : 그래서 내 지금 ImageView 작업처럼 보이는 - 설정 여백을 0으로? - Android Device Monitor에서 레이아웃을 검사하거나 배경색을 사용하여 공간의 어느 부분이 ImageView에서 왔는지, 컨테이너의 내용을 정확히 알 수 있습니까? –

+0

이미지 상단과 하단에 여백이 있는지 확인하십시오. – kgandroid

+0

@kgandroid : 아니요. 이미지에 여백이 없습니다. – Atul

답변

0

사용 android:scaleType="fitXY" (주 내가 관찰하는 이미지의 폭이 높이보다 큰 경우에만 여백이 나타납니다 이미지가 관찰 폭 높이보다 훨씬 작은 더 마진이없는하십시오.) 모두의 의견. android:adjustViewBounds="true"에서 ImageView으로 설정하면 문제가 해결됩니다. 그냥 내 머리 위로 떨어져

<ImageView 
     android:id="@+id/message_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:adjustViewBounds="true"/> 
+0

이 이미지는 세로로 늘어납니다. 하지만 힌트를 주셔서 감사합니다. 마지막으로'android : adjustViewBounds = "true"'가 나를 위해 일했다. – Atul