5

In a Listview I want create a square button that is as wide as the list item is high. I don't want to set fixed width and height as it should work for different resolutions.

Is is possible?

4

2 に答える 2

0

レイアウト xml ファイルで、parent を埋めるように指示します。

<Button android:layout_width="fill_parent" .... ></Button>

または、API を使用している場合は、setLayoutParamsを使用できるはずです。

myButton.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
于 2010-02-12T12:14:25.327 に答える
0

レイアウトの寸法や位置を密度に依存しない方法で表現するには、仮想的なピクセル単位である密度非依存ピクセル(dip) を使用します。

于 2010-02-12T18:08:39.123 に答える