以下のレイアウトは、ListView
の1つのアイテムのモデルです。ご覧のように、3つのTextViewは、それぞれが行全体のスペースのうち.3
を占めているので、それぞれから分離されています。リストビュー内のアイテム間にスペースを追加する方法
問題は、ListView
にアイテムを追加すると、3つのTextView
がちょうど互いにリンクされていることがわかりました。
Adam USA M
私はそれぞれのTextViewを分離するいくつかのスペースで画面上にその行を見ることを期待が、何が起こることは私のような何かを得ることである:例えば、次のものが含まれ、私はListView
に項目を追加したいのは、想定してみましょう次のようになります。
AdamUSAM
なぜこの問題が発生し、解決するのですか?
model_view:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:text="Name"/>
<TextView
android:id="@+id/tvAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:text="Address: "/>
<TextView
android:id="@+id/tvGender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:text="gender: "/>
</LinearLayout>
更新:今すぐ
は、私は次のようにレイアウトを変更しましたが、問題は3 textviewsが互いにクリンチ出現していることであるが持続されます間隔を置かずに
レイアウト
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3">
<TextView
android:id="@+id/tvName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name: "
android:focusable="false"/>
<TextView
android:id="@+id/tvAddress"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Address: "
android:focusable="false"/>
<TextView
android:id="@+id/tvGender"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="gender: "
android:focusable="false"/>
</LinearLayout>
画面がショット:
あなたはスクリーンショットを共有できますか? – Enzokie
@Enzokieスクリーンショットが追加されました – user2121
'xml'というレイアウトは大丈夫ですが、正しいレイアウトファイルを展開していますか? – Pztar