I'm doing a project in which I want to set an image in the center.I'm using TableLayout and I want set this image in FrameLayout. If u have any idea so please suggest me. Its very urgent. Thanx to all. Here is my code:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:scaleType="center"
>
<com.nexbits.digitechi.DrawCanvas
android:id="@+id/SurfaceView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<ImageButton
android:id="@+id/imageButton5"
android:layout_weight="1"
android:padding="20dip"
android:layout_gravity="center_horizontal"
android:onClick="video"
android:src="@drawable/ic_webcamera" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:padding="20dip"
android:src="@drawable/ic_twitter64" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_weight="1"
android:padding="20dip"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_brightness64" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_weight="1"
android:padding="20dip"
android:layout_gravity="center_horizontal"
android:src="@drawable/microscope" />
</TableRow>
</TableLayout>
Use this line in your Frame layout:
android:layout_gravity="center_vertical|center_horizontal"
android:foregroundGravity="center"
<com.nexbits.digitechi.DrawCanvas
android:id="@+id/SurfaceView"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
I achieved it by adding to Child (something inside frame layout)
android:layout_gravity="center"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With