FrameLayout布局下让图片居中的方法

如果图片的ImageView设为wrap_content,是可以居中的,但对于我是相册,需要设为fill_parent才能进行缩放。通过网上找资料,只要把组件放到一个LinearLayout下就可以了。

项目中的代码是:

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:gravity="center"

    android:layout_gravity="center"

     >

    <LinearLayout

        android:layout_width="fill_parent"

       android:layout_height="fill_parent" 

       android:orientation="vertical"

       android:gravity="center"

       android:layout_gravity="center">

         <ImageView

        android:id="@+id/pic"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:scaleType="matrix"

        android:layout_gravity="center"

        android:gravity="center" />

        

    </LinearLayout>

   



    <ProgressBar

        android:id="@+id/progress"

        style="?android:attr/progressBarStyleLarge"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_gravity="center" 

        />



</FrameLayout>

你可能感兴趣的:(FrameLayout)