Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何在FrameLayout中心设置图像大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在做一个项目,我想在中心设置一个图像.我正在使用TableLayout,我想在FrameLayout中设置这个图像.如果您有任何想法,请建议我.这非常紧迫.对所有人而言.这是我的代码
<TableLayout xmlns:android="http://scheR_110_11845@as.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>

解决方法

在Frame布局中使用此行:
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" />

大佬总结

以上是大佬教程为你收集整理的android – 如何在FrameLayout中心设置图像全部内容,希望文章能够帮你解决android – 如何在FrameLayout中心设置图像所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。