我尝试使用此 xml 代码制作自定义视图:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher"/>
</LinearLayout>
我用这段代码运行通知:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.notification_layout);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setContent(remoteViews).setSmallIcon(R.drawable.ic_launcher);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(20, mBuilder.build());
}
这是结果:
为什么“match_parent”不使用通知的完整高度?
我希望红色区域与通知的高度相同,而不使用“dip”统一。我使用安卓 4.2.2。谢谢 !