Android 애플리케이션의 알림 영역에 아이콘을 설정하려고합니다.알림 영역에 아이콘을 올바르게 설정하는 방법?
나는 티커의 아이콘이 잘린 것처럼 보였다. 티커가 사라지면 알림 영역에있는 아이콘이 잘 보입니다. 내 알림 내 사용자 지정 레이아웃
여기String msg = "Calculation completed. Tap to view result.";
final Intent restartActivityIntent = new Intent(context, NumberOfPrimesActivity.class);
final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, restartActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
RemoteViews mContentView = new RemoteViews(context.getPackageName(), R.layout.custom_notification);
mContentView.setImageViewResource(R.id.image, R.drawable.two);
mContentView.setTextViewText(R.id.text, msg);
Notification.Builder notificationBuilder = new Notification.Builder(context).setSmallIcon(R.drawable.two).setContentTitle("Sum of Primes").setContentText(msg).setAutoCancel(true).setContentIntent(pendingIntent).setTicker(msg);
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ID, notificationBuilder.build());
입니다 : : 여기 아이콘을 설정 내 코드는
여기<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#7777"
android:padding="3dp">
<ImageView android:id="@+id/image"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginRight="10dp"
android:contentDescription="alert"
android:src="@drawable/two" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:textSize="24sp" />
</LinearLayout>
내 res
디렉토리는 모양을 같은 :
ldpi
폴더에있는 two.png
파일의 크기는 22x22입니다.
마지막으로 두 개의 스크린 샷이 있습니다. 첫 번째 아이콘이 잘린 상태로 티커가 표시됩니다. 두 번째 아이콘은 티커가 사라진 후에 아이콘을 보여줍니다. 아이콘은 두 번째 스크린 샷에서 잘 보입니다.
업데이트
mdpi
폴더에있는 two.png
파일의 경우 48x48이입니다.
파일의 hdpi
폴더는 72x72입니다.
xhdpi
폴더의 two.png
파일의 크기는 92x92입니다.
폴더의 two.png
파일은 144x144입니다.
시뮬레이터를 사용하여 프로그램을 테스트하고 있습니다. 두 개의 시뮬레이터가 있습니다. 하나는 Nexus 7 (800 x 1280)이고 다른 하나는 Nexus 4 (768 x 1280)입니다.
두 시뮬레이터 모두에서 티커의 아이콘이 잘립니다.
스크린 샷에서 기기의 화면 밀도는 얼마입니까? 다른 폴더의 two.png 차원은 무엇입니까? – TactMayers
방금 내 질문을 업데이트했습니다. –