开发者

Table Layout Auto Adjust the ImageView

I am using a table layout for placing the the ImageView,I am adding 5 imageView in a row ,now I want depending on screen width all ImageViews automatically adjust distance among them,how I can do this,my TableLayoutas below . .

    <TableLayout android:id="@+id/tableLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/transparent_background">
            <TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content" android:stretchColumns="*" android:layout_width="fill_parent">
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1" android:layout_width="wrap_content" android:src="@drawable/tea"></ImageView>
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView2" android:layout_width="wrap_content" android:src="@drawable/bye"开发者_JAVA百科 ></ImageView>
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView3" android:layout_width="wrap_content" android:src="@drawable/brb" ></ImageView>
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView4" android:layout_width="wrap_content" android:src="@drawable/pizza" ></ImageView>
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView5" android:layout_width="wrap_content" android:src="@drawable/beer"></ImageView>          
            </TableRow>             
            <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>
            <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>
            <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>

        </TableLayout>


hi first u have to get the screen resolution based on the resolution u have to change the image view size.use this code find screen length and height

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();
int height = display.getHeight();

try this link it ll help u for dynamically change the image view

set extended ImageView width and height programatically - android

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜