tags:

views:

163

answers:

2

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

A: 

In your layout xml file tell it to fill it's parent:

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

Or if you are using the API I think you should be able to use setLayoutParams:

myButton.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
Maxwell Troy Milton King
the row consists of a TextView and a Button, the button should be has wide as the row is high. If a smaller font is used the button should adjust.
friedger
A: 

Use density independent pixel (dip) which is a virtual pixel unit to express layout dimensions or position in a density-independent way.

dtmilano