1

図のようなレイアウトを作りたい

ここに画像の説明を入力

listView Scroll を個別に作成し、textView と ImageView を代わりにするにはどうすればよいですか?

4

5 に答える 5

1

以下のコードのように xml レイアウトを置き換えるだけです。

<?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:background="@android:color/white"
    android:padding="5dp"
    android:weightSum="2"
    android:orientation="vertical" >

    <LinearLayout android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical">

        <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Small Text"
        android:layout_gravity="right"
        android:textColor="@android:color/black"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </ListView>

    </LinearLayout>

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:src="@drawable/yourimg" />

</LinearLayout>

スクリーンショットの下の出力が与えられた上記のxml:

ここに画像の説明を入力

于 2013-07-10T11:13:42.243 に答える
0

Lower Steady Image View では、以下を使用できます。フッターとして設定するテキストで構成されるフッター ビュー レイアウトを作成してから、試してください。

View footerView = ((LayoutInflater) ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
ListView.addFooterView(footerView);

ヘッダーの場合: 私にとって有効な解決策は、次のような見出しのある行とリストのある行を持つ TableLayout を作成することです。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

   <include layout="@layout/header" />

   <ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
   />

</TableLayout>
Please make sure that the ListView has @android:id/list as the ID.

また

むしろ、Google が Android のリストビューにヘッダーとフッターを追加すると、はるかに役立ちます

于 2013-07-10T11:01:42.980 に答える
0

疑似コードで申し訳ありませんが、後でもっと良い試みを試すことができますが、必要なものは次のとおりです。

RelativeLayout
    TextView - align top
    ImageView - align bottom
    ScrollView - align above ImageView, align below TextView
于 2013-07-10T11:02:08.313 に答える
0

向きを縦に揃えた線形レイアウトを作成します。必要に応じて、重みを付けて textview listview と imageview を追加します。3 つのコンポーネントすべてについて、layout_height を 0dp にすることを忘れないでください。

于 2013-07-10T11:02:35.197 に答える