我試圖做一些「聊天視圖」與像短信iPhone應用程序的氣泡。 這是行我在XML編輯器完成的:在android中的按鈕位置
http://img44.imageshack.us/i/xml.png/
但是,當我啓動我的申請,我得到這個:
http://img59.imageshack.us/i/resultt.png/
我不知道爲什麼按鈕回答很遠我的相對佈局邊框!這是對話泡泡的XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:background="@drawable/bulle_chat"
android:layout_width="fill_parent">
<ImageView android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_height="40sp"
android:layout_width="40sp"
android:id="@+id/ImageViewPhoto"
android:scaleType="fitXY"
android:layout_margin="8sp"
android:src="@drawable/lady">
</ImageView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ImageViewPhoto"
android:layout_alignTop="@+id/ImageViewPhoto"
android:id="@+id/TextViewPseudo"
android:text="Pseudo"
android:textColor="#242424"
android:textStyle="bold">
</TextView>
<TextView android:layout_below="@id/TextViewPseudo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/TextViewDate"
android:text="Date"
android:layout_toRightOf="@+id/ImageViewPhoto">
</TextView>
<Button android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:id="@+id/ButtonAnswer"
android:layout_height="40sp"
android:layout_width="40sp"
android:layout_margin="8sp">
</Button>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ImageViewPhoto"
android:layout_alignLeft="@+id/ImageViewPhoto"
android:textColor="#000000"
android:text="BlbalblablbalbalbalbalbalablabalbalablaballabalbBlbalblablbalbalbalbalbalablabalbalablaballabalbalbalaBlbalblablbalbalbalbalbalablabalbalablaballabalbalbalablablaalbalabla"
android:id="@+id/TextViewMessage"
android:layout_alignRight="@+id/ButtonAnswer"
android:paddingBottom="15sp">
</TextView>
</RelativeLayout>
這是適配器getView()方法(僞=暱稱):
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = ctx.getLayoutInflater();
View v = inflater.inflate(R.layout.chat_row, null);
TextView pseudo = (TextView)v.findViewById(R.id.TextViewPseudo);
TextView date = (TextView)v.findViewById(R.id.TextViewDate);
TextView message = (TextView)v.findViewById(R.id.TextViewMessage);
ImageView icon = (ImageView)v.findViewById(R.id.ImageViewPhoto);
Button b = (Button)v.findViewById(R.id.ButtonAnswer);
b.setId(position);
b.setOnClickListener((OnClickListener) ctx);
pseudo.setText(listMessages.get(position).getPseudo());
pseudo.setTextColor(0xFF000000);
date.setText(listMessages.get(position).getDate());
date.setTextColor(0xFF000000);
message.setText(listMessages.get(position).getText());
message.setTextColor(0xFF000000);
message.setGravity(Gravity.CLIP_HORIZONTAL);
if (listMessages.get(position).getThumb()!=null){
icon.setImageBitmap(listMessages.get(position).getThumb());
} else {
icon.setImageResource(R.drawable.unknown);
}
return v;
}
正如你所看到的,我設置佈局alignement父權利和頂部爲真,但它不起作用。其他問題:如果我想改變我的按鈕的背景,這個消失!
感謝您的幫助(對不起我的英文)!
不能看到你的屏幕截圖進入 – WarrenFaith 2010-08-10 14:23:48