2016-04-21 81 views
0

我正在制作一个显示自定义通知栏的应用程序。我面临的问题是视图中的ImageButton被水平拉伸。RemotesView中的ImageButton延伸

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="horizontal" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:weightSum="4" android:gravity="center_horizontal"> 

    <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:id="@+id/a" 
      android:scaleType="centerInside" 
      android:background="@drawable/a"/> 
    <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:id="@+id/b" 
      android:scaleType="centerInside" 
      android:background="@drawable/b"/> 
    <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:id="@+id/c" 
      android:scaleType="centerInside" 
      android:background="@drawable/c"/> 
    <ImageButton 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:id="@+id/d" 
      android:scaleType="centerInside" 
      android:background="@drawable/d"/> 
</LinearLayout> 
.. 
RemoteViews rv = new RemoteViews(getPackageName(), R.layout.notification); 
notification.contentView = rv; 

图像I中所用的尺寸为最高72x72。当我的设备倾斜到横向模式时,图像会变得更糟,因为图像倾向于填充通知栏。
有没有办法确保图像均匀缩放(向下),并在每个ImageButton之间留出一些空间以使通知看起来更好?

回答

0

对于任何有类似问题的人,解决方案是fitCenter而不是属性中的centerInside