我做一个简单的聊天应用程序,我想表明类似气球iphone的短信应用.
所以我正在做一个Activity有ListView一定布局的人.这是我的布局:
/* Activity Layout */
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView android:id="@+id/chat_log"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stackFromBottom="true"
android:layout_marginTop="50dp"
android:transcriptMode="alwaysScroll"
android:layout_weight="1"
android:cacheColorHint="#00000000"
android:clickable="false"
/>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<EditText android:id="@+id/chat_input_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="bottom"
/>
<Button android:id="@+id/chat_send_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/chat_send_button"
/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
其他:
/* Row Layout */
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/userprofile_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/chat_ballon_left" >
<TextView
android:id="@+id/chat_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dp"
android:text="haasdasdasdasdasdasdasdoo" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
这是结果.
我的问题:
android:clickable="false"了气球是可点击的.我尝试在xml中创建一个Android聊天布局,但我无法得到我想要的东西.这是我能得到的最接近的:
<?xml version="1.0" encoding="utf-8"?>
<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="fill_parent"
android:layout_weight="10" >
<TextView
android:text="@string/text"
android:id="@+id/textOutput"
android:layout_width="wrap_content"
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="fill_parent"
android:layout_weight="100"
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="fill_parent">
<requestFocus></requestFocus>
</EditText>
<Button android:layout_weight="1" android:text="Send"
android:layout_height="45dp" android:layout_width="125dp"
android:id="@+id/btnSend"></Button>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这导致了这一点.这种布局的问题(相当混乱)是我不希望较低的LinearLayout的大小是百分比.我希望它是一个固定的高度,ScrollView中的TextView(这是使大文本滚动的最佳方式吗?)来填满屏幕的其余部分.我一定是缺少一些属性或东西.