gpt4 book ai didi

android - 通知高度不正确 "match_parent"

转载 作者:太空狗 更新时间:2023-10-29 12:47:04 24 4
gpt4 key购买 nike

我尝试使用此 xml 代码制作自定义 View :

<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());
}

这是结果:

screenshot

为什么“match_parent”不使用通知的全高?

我希望红色区域与通知具有相同的高度,而不使用“dip”统一。我使用安卓 4.2.2。谢谢!

最佳答案

您尝试过使用 RelativeLayout 吗?还可以在 ImageView 标签中使用这些属性

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

关于android - 通知高度不正确 "match_parent",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17052004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com