我正在制作一个显示自定义通知栏的应用程序。我面临的问题是视图中的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; 我使用的图像大小为72x72。当我的设备倾斜到景观模式时,图像会更糟糕,因为图像会填充通知栏。
是否有一种方法可以确保图像被统一缩放(向下),并在每个ImageButton之间留出一些空间以使通知看起来更好?
发布于 2016-04-23 14:00:31
对于任何有类似问题的人,解决方案是fitCenter,而不是android:scaleType属性中的centerInside。
https://stackoverflow.com/questions/36771553
复制相似问题