通知不正确&QUOT高度; match_parent" [英] Height of notification incorrect "match_parent"

查看:190
本文介绍了通知不正确&QUOT高度; match_parent"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试做一个自定义视图与该XML code:

I try to make a custom view with this xml code:

<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>

和我运行的通知本code:

and i run notification with this code:

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不使用通知的整个高度?

why "match_parent" does not use the full height of the notification ?

我要红区不相同高度的通知,不使用浸的统一。我采用Android 4.2.2。谢谢!

I want the red zone does the same height as the notification, without use "dip" unity. I use android 4.2.2. Thank you !

推荐答案

你有没有尝试使用RelativeLayout的呢?并且还玩弄了ImageView的标记这些属性。

Did you try using a RelativeLayout instead? And also play around with these attributes in the ImageView tag

android:scaleType="centerCrop"
android:adjustViewBounds="true"

这篇关于通知不正确&QUOT高度; match_parent&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆