简体   繁体   English

在TableLayout中调整按钮和图像的大小

[英]Resize Buttons and Image in TableLayout

I've been trying to get the ImageView and the 3 Buttons all in the same size (fitting the parent TableLayout) but for me it's turning out to be impossible and I was hoping someone could help me fix this problem in the .xml file. 我一直在尝试使ImageView和3个按钮的大小都相同(适合父TableLayout),但对我来说这是不可能的,我希望有人可以帮助我解决.xml文件中的问题。

http://i.imgur.com/xgsIC.png http://i.imgur.com/xgsIC.png

This is the TableLayout I'm trying to put together and this is the code inside of it: 这是我要放在一起的TableLayout,这是其中的代码:

    <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="*" >
            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
                <ImageView
                    android:id="@+id/iFoto"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:scaleType="centerCrop"
                    android:background="#000000"
                    android:padding="1dp"
                    android:src="@drawable/i_background" />
                <TableLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:stretchColumns="*" >
                    <TableRow
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >
                        <ImageButton
                            android:id="@+id/button1"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:background="@anim/btblue"
                            style="@style/ButtonText"
                            android:src="@drawable/ic_launcher" />
                    </TableRow>
                    <TableRow
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >
                        <ImageButton
                            android:id="@+id/button2"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:background="@anim/btblue"
                            style="@style/ButtonText"
                            android:src="@drawable/ic_launcher" />
                    </TableRow>
                    <TableRow
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >
                        <ImageButton
                            android:id="@+id/button3"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:background="@anim/btblue"
                            style="@style/ButtonText"
                            android:src="@drawable/ic_launcher" />
                    </TableRow>
                </TableLayout>
            </TableRow>
        </TableLayout>

This is what I was hoping to get: 这就是我希望得到的:

http://i.imgur.com/vSm8q.png http://i.imgur.com/vSm8q.png

Can someone help me with this ? 有人可以帮我弄这个吗 ? Thank you. 谢谢。

Try to do like this.. 尝试这样做

Change your Imageview Width&height attributes to like this.. 更改您的Imageview宽度和高度属性,就像这样。

<ImageView
            android:id="@+id/iFoto"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:adjustViewBounds="true"
            android:background="#000000"
            android:padding="1dp"
            android:scaleType="centerCrop"
            android:src="@drawable/bgd7" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM