6
我試圖用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>
這會導致this。 這個佈局的問題(這很麻煩),是我不希望較低的LinearLayout的大小是一個百分比。我希望它是一個固定的高度,並且ScrollView中的TextView(這是製作大文本滾動的最佳方式?)來填充屏幕的其餘部分。我必須缺少一些屬性或其他東西。
非常感謝您剩餘的空間!我可以問一下0dip的含義嗎?它是否與0dp相同? –
我相信這對Android意味着同樣的事情。關於使用這個值的唯一重要的事情就是它對佈局邏輯的效率。它用於告訴Android它的這個值(寬度或高度)來執行加權。沒有什麼大不了的,只要使用任何可以轉化爲0的比例即可! – Kurru