2011-11-23 82 views
2

嗨,大家好,我沒有這個問題的答案。希望你能幫忙。 layout_gravity屬性爲中心,當我將縮放類型屬性設置爲矩陣時,它不起作用。而且,我正在使用該圖像視圖的縮放縮放。所以如果我可以設置圖像,並設置圖像是小的那麼它會很好。希望得到更好的迴應。在此先感謝...Android ImageView佈局引力不起作用

編輯#1: 我的ImageView如下:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="fill_parent" 
android:layout_height="fill_parent" android:background="@drawable/bg"> 

<LinearLayout android:layout_width="fill_parent" 
    android:id="@+id/linear_titile_bar" android:layout_height="wrap_content" 
    android:background="@drawable/top_black_logo_bg"> 

    <Button android:layout_width="wrap_content" android:id="@+id/myphotos_gridview_back" 
     android:layout_height="wrap_content" android:background="@drawable/back_gray_bt" 
     android:layout_gravity="center_vertical" android:layout_margin="5dip"> </Button> 
</LinearLayout> 

<LinearLayout android:layout_width="fill_parent" 
    android:id="@+id/nameTitlebar" android:layout_below="@+id/linear_titile_bar" 
    android:layout_height="wrap_content" android:background="@drawable/title_gray_bg"> 

    <TextView android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:gravity="center" 
     android:text="MY PHOTOS" style="@style/ivideodate.blue.large"></TextView> 
</LinearLayout><!-- android:layout_above="@+id/FooterLayout" --> 

<LinearLayout android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:layout_below="@+id/nameTitlebar" 
    android:layout_above="@+id/FooterLayout" android:gravity="center"> 

    <ImageView android:layout_width="fill_parent" android:scaleType="matrix" 
     android:layout_gravity="center" android:layout_height="fill_parent" 
     android:id="@+id/ProfileImageView" /> 

</LinearLayout> 

<LinearLayout android:layout_height="wrap_content" 
    android:background="@drawable/my_photo_edit_but_bg" 
    android:layout_width="fill_parent" android:layout_alignParentBottom="true" 
    android:id="@+id/FooterLayout" android:orientation="vertical" 
    android:gravity="center"> 

    <Button android:background="@drawable/set_profile_pic_bt" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:scaleType="fitCenter" android:id="@+id/setprofileimage" /> 
    <Button android:background="@drawable/delete_photo_bt" 
     android:layout_width="wrap_content" android:layout_marginTop="5dip" 
     android:layout_height="wrap_content" android:scaleType="fitCenter" 
     android:id="@+id/deleteimage" /> 

</LinearLayout> 

</RelativeLayout> 
+0

郵編你是如何設置ImageView的嚴重性? – user370305

+0

@ user370305我已更新我的問題... – Dinash

+0

如果您不介意可以發佈整個xml文件。 – user370305

回答

3

的問題是你的LinearLayout是水平的,孩子已經FILL_PARENT,因爲它的寬度。所以除非你將寬度指定爲wrap_content並將其與水平居中對齊,否則不起作用。

+0

我不能使用wrap_content作爲即時通訊使用捏縮放..如果圖像大小不會有問題,但如果圖像尺寸很小,則會出現問題... – Dinash

0

在Android XML試試這個佈局重心

 <?xml version="1.0" encoding="utf-8"?> 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 
     <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:gravity="center"> 
     <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_launcher" 
     /> 
     </LinearLayout> 
     </LinearLayout>   
-1

利用重力

+0

Imageview沒有場重力,只有layout_gravity –

+0

Imageview has沒有場地引力,只有layout_gravity – dutchman711