基本上,如果用戶要輸入大量文本,我的listView項目會被截斷。我尋找了一個解決方案,但找不到一個,所以希望這也能幫助其他人。是否可以展開列表視圖項(textView)以包含所有輸入?
我已經設置的TextView和ListView爲wrap_content 我已經設置的TextView到Android:單線= 「假」
我的個人列表項的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tvItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/bDelete"
android:layout_alignBottom="@+id/bDelete"
android:layout_toLeftOf="@+id/bDelete"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/bDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="15dp"
android:layout_alignParentTop="true"
android:layout_marginRight="5dp"
android:text="DONE" />
</RelativeLayout>
我的XML對於整個主屏幕布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/artport">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:layout_alignParentRight="true"
android:id="@+id/bAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add" />
<EditText
android:id="@+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/bAdd"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/bAdd"
android:contentDescription="@string/addItemContentDescription"
android:ems="10"
android:hint="@string/addItemHint" />
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ListView
android:id="@+id/myListView"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
/>
<Button
android:id="@+id/bClearedList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/ad"
android:layout_weight="0"
android:text="View Deleted Items" />
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:adUnitId="ca-app-pub-XXXXXXXXXXXXXXXXXXX"
ads:loadAdOnCreate="true"
android:layout_alignParentBottom="true"
>
</com.google.ads.AdView>
</LinearLayout>
</LinearLayout>
什麼是你的代碼的問題? –
以及圖片解釋了這一切,textView越來越切斷 – Pythagoras
你是否在ListView中膨脹listitem佈局? @Pythagoras – GrIsHu