2

こんにちはみんな私はこの質問に対する答えを持っていません。お役に立てば幸いです。中心としてのlayout_gravityプロパティは、scaletypeプロパティをmatrixに設定すると機能しません。また、その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>
4

3 に答える 3

4

問題は、あなたの linearLayout が horizo​​ntal であり、子の幅が fill_parent であることです。したがって、幅を wrap_content として指定し、水平方向の中央に揃えない限り、機能しません。

于 2011-11-23T11:01:15.690 に答える
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>          
于 2011-11-23T11:05:19.850 に答える
-1

レイアウト重力の代わりに重力を使用する

于 2014-06-13T18:34:45.977 に答える