我正在嘗試爲聊天室創建一個語音氣泡。每個講話泡泡都有附帶的xml佈局。Android ImageView在下面的FrameLayout裏面不match_parent GingerBread
我通過設置的TextView實現這一到WRAP_CONTENT,語音泡沫的ImageView到match_parent和frame_layout到WRAP_CONTENT。以便文字後面的speech_bubble圖像根據泡泡中文字的大小進行縮放。
我設置寬度上TextView的匹配父和WRAP_CONTENT高度,出於某種原因,它作爲Ice Cream Sandwich的(安卓4.1)需要完美的作品。 但薑餅內部imageView語音氣泡不縮放到match_parent,使文本可以整齊地放在泡泡內。 在薑餅的內部圖像查看保持相同的大小始終,無論文字和文字溢出氣泡之外。儘管 的的FrameLayout擴展到WRAP_CONTENT,則ImageView的不match_parent,因爲它應該。
爲什麼會發生這種情況的任何想法?是否有另一個參數,我可以設置通過xml或我可以調用編程方式來解決這個問題的方法?
謝謝!在ICS
正確行爲:
薑餅不正確的行爲: Incorrect Behavior in GingerBread
XML佈局:
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/speech_bubble_framelayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/color_transparent"
android:layout_toRightOf="@id/message_user_imageView">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/message_background_imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:scaleType="fitXY"
android:layout_centerInParent="true"
android:textColor="@color/color_brown_mud"
android:background="@drawable/chat_bubble_flipped"
/>
<TextView
android:id="@+id/message_textView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:maxEms="10"
android:background="@color/color_transparent"
android:textColor="@color/color_brown_uiDesign_pallete"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center_horizontal"
android:text="Message"
android:padding="5dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
/>
</FrameLayout>
</merge>
解決了這個問題。我用alignBottom和alignRight與一些填充。謝謝! – Bala