2016-09-29 105 views
0

我想设置适合50%屏幕的图像,但我无法做到这一点。如何在适合50%屏幕的android中设置图像

这里我的代码

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

<LinearLayout 
    android:id="@+id/frontImage" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:layout_weight="2" 
    > 
    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/background"/> 
</LinearLayout> 

回答

1
<LinearLayout 
     android:id="@+id/frontImage" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:weightSum="2" 
     > 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="0px" 
      android:layout_weight="1" 
      android:src="@mipmap/ic_launcher" /> 

    </LinearLayout> 
+0

谢谢@shahzain阿里 –

+0

接受并给予好评我的答案,如果它的工作原理:) –