2015-09-25 49 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一样是很重要的。

相关问题