블루투스 연결시에는 정상적으로 Notification이 Title과 text image가 다 뜹니다.
아래와 같이 정상적으로 뜹니다.
이미지 타이틀 X
텍스트
그러나 미연결시에는 타이틀과 텍스트가 사라지고,
이미지가 중간으로 오면서 x는 그대로 위치합니다.
이미지 x
아래는 소스와 layout 입니다.
소스에서
if(BluetoothService.check_mState!=3){
// contentView.setImageViewResource(R.id.image, R.drawable.bt_dis);
이미지를 주석 처리할경우에는
title과 text가 뜹니다.
이미지과 title text간의 충돌인거같은데.. 이해가 안되서 이렇게 글을 올립니다.
<소스>
Notification notification;
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification_layout);
if(BluetoothService.check_mState!=3){
contentView.setImageViewResource(R.id.image, R.drawable.bt_dis);
contentView.setTextViewText(R.id.title, getResources().getString(R.string.noti_title));
contentView.setTextViewText(R.id.text,"연결안됨");
contentView.setOnClickPendingIntent(R.id.finish_button, pfinishIntent);
notification = new Notification.Builder(this)
.setSmallIcon(R.drawable.bt_dis)
.setContent(contentView)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_MAX)
.build();
}else{
contentView.setImageViewResource(R.id.image, R.drawable.ic_launcher);
contentView.setTextViewText(R.id.title, getResources().getString(R.string.noti_title));
contentView.setTextViewText(R.id.text, getResources().getString(R.string.noti_content));
contentView.setOnClickPendingIntent(R.id.finish_button, pfinishIntent);
notification = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContent(contentView)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_MAX)
.build();
}
startForeground(NOTIFICATION_ID, notification);
<layout>
<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:padding="10dp" >
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp" />
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
android:textColor="#000000"
style="Custom Notification Title" />
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
android:textColor="#000000"
android:layout_below="@id/title"
style="Custom Notification Text" />
<ImageButton
android:id="@+id/finish_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:layout_alignParentRight="true"
android:background="@drawable/x"/>
</RelativeLayout>