18

またはTextViewのすべての行にパディングを設定する必要があります。and child ( ,...)を使用しようとしましたが、結果はありません。どのようにできるのか?ありがとうListViewExpandableListViewandroid:paddingpaddingLeft

編集:

の商品コードですExpandableListView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="20dp" >

    <TextView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="wrap_content"
        android:id="@+id/titleScheda"
        android:text="TextView"
        android:layout_width="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:padding="20dp" />

</LinearLayout>

パディングが 2 つのタグの 1 つだけに設定されていても、layout と の両方にパディングを設定するとTextView機能しません。

編集 :

解決しました。問題はSimpleExpandableListAdapter宣言の Java コードにありました。標準のレイアウトを使用するとカスタマイズすることはできませんが、拡張可能なコンテンツにカスタム レイアウトを使用することは、あらゆるカスタマイズを可能にするソリューションです。

4

3 に答える 3

16

テンプレートファイル(xmlレイアウト)を使用してリストビューにアイテムを追加していると思います。そうでない場合は、最初にそれを実装する必要があります。

そのレイアウトファイルでは、これを行うことができます:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp" >
    <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/text" />
</LinearLayout>

LinearLayout はパディングを作成し、TextView をラップします。

于 2012-09-03T17:02:36.017 に答える
4
for(int i=0; i< listview.getChildCount();i++) 

  listview.getChildAt(i).setPadding(10,10,10,10);
于 2012-09-03T15:28:47.210 に答える