2015-09-25 48 views
-3

enter image description hereImageView的比另一個imageview的

我想如圖所示PIC編程來佈置兩個imageviews。一張是個人資料照片,一張是藍色圓圈的白色鉛筆。

這是我設置了主型材PIC

int px = metrics.heightPixels/4; 
profilePic = (ImageView)findViewById(R.id.profilePic); 
profilePic.getLayoutParams().width = px; 
profilePic.getLayoutParams().height = px; 

如果我在XML做到這一點,它會創建在不同的屏幕尺寸問題的寬度和高度。 如何實現這個編程?

回答

1

將兩個imageview放在relativelayout中。使圖像呈圓形並將相對佈局中的小圖像視圖與底部左佈局重力對齊。

0

試試以下,

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:gravity="center_horizontal" > 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="match_parent" 
     android:layout_height="250dp" 
     android:layout_marginTop="100dp" 
     android:background="@drawable/ic_launcher" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="-20dp" 
     android:background="@drawable/ic_launcher" /> 

</LinearLayout> 

這裏主要的是給浮動保證金-20一樣是很重要的。

相關問題