2012-09-21 250 views
1

我正在爲Android創建聊天應用程序。聊天畫面應該如何?任何人都可以告訴我應該在XML佈局中使用哪些視圖?它是一個edittext和一個listview?請幫助。我需要製作一個聊天屏幕,就像我們在Gtalk中看到的那樣。兩個人的聊天消息應該與屏幕的兩側對齊(請參閱Gtalk聊天框對齊樣式)。這就是我想要的。如何實現這種佈局? http://upload.wikimedia.org/wikipedia/en/7/75/Google_talk.gifAndroid聊天應用程序-xml佈局

+0

@raghav蘇德我可以從服務器獲取用戶的詳細信息,但我不知道如何顯示聊天雙方在交談的人的信息。我是否需要單一的listview,一個edittext和一個提交按鈕或textviews和edittext和button?這是我的疑問 –

+0

我建議你去閱讀一些關於適配器的教程,試着實現教程,然後,如果你在某個特定點有問題,請回來問。 – Budius

+0

@布迪斯我做了所有這些事情。仍然我很困惑哪種方式更好,請建議一個 –

回答

2

得到了合適的。所以,我分享在這裏

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" > 
    <TextView 
     android:text="@string/text" 
     android:id="@+id/textOutput" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:paddingLeft="5dp" 
     android:paddingRight="5dp" 
     android:paddingTop="5dp" /> 
</ScrollView> 

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    android:paddingBottom="5dp" 
    android:baselineAligned="true"> 
    <EditText android:layout_weight="1" android:id="@+id/textInput" 
     android:layout_height="45dp" android:layout_width="0dip"> 
     <requestFocus></requestFocus> 
    </EditText> 
    <Button android:text="Send" 
     android:layout_height="45dp" android:layout_width="125dp" 
     android:id="@+id/btnSend"></Button> 
</LinearLayout>