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?
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?
レイアウト xml ファイルで、parent を埋めるように指示します。
<Button android:layout_width="fill_parent" .... ></Button>
または、API を使用している場合は、setLayoutParamsを使用できるはずです。
myButton.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
レイアウトの寸法や位置を密度に依存しない方法で表現するには、仮想的なピクセル単位である密度非依存ピクセル(dip) を使用します。