2016-08-05 7 views
0

notificationを特別に作成したかったので、デフォルトの種類の通知ではなくリモートビューを使用しています。私はその種の拡張通知や何かを使用することができることを知っている...問題は、この種の通知では、私はサイズを変更することができるかどうかわからない...通知のデフォルトサイズを変更する(Android)

RemoteViews contentView = new RemoteViews(packageName, R.layout.new_event_notification); 
contentView.setTextViewText(R.id.eventName,eventToDisplay.getName()); 
contentView.setTextViewText(R.id.eventDayOfTheWeekTxt, dateTextToDisplay.getDateTextToDisplay(context,eventToDisplay.getEventDate()));   contentView.setTextViewText(R.id.eventTimeTxt,context.getString(R.string.at_time) + " " + eventToDisplay.getEventTime().toString()); 

contentView.setOnClickPendingIntent(R.id.attendButton, acceptPendingIntent); 
contentView.setOnClickPendingIntent(R.id.declineButton, declinePendingIntent); 
//Building the notification 
NotificationCompat.Builder eventsNotification = new NotificationCompat.Builder(context) 
    .setSmallIcon(R.drawable.notification_template_icon_bg) 
    .setContentText("Incoming notifications") 
    .setContent(contentView); 

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
//Sending out the notification 
notificationManager.notify(notificationID, eventsNotification.build()); 

通知のレイアウトXML::それが作成された後

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:weightSum="1" 
    android:layout_marginTop="-4dip"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Event Name" 
     android:tag="event" 
     android:id="@+id/eventName" 
     android:layout_gravity="left" 
     android:textColor="@android:color/black" 
     android:textSize="21sp" 
     android:layout_alignParentTop="true" 
     android:layout_alignRight="@+id/eventDayOfTheWeekTxt" 
     android:layout_alignEnd="@+id/eventDayOfTheWeekTxt" /> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Going" 
     android:id="@+id/attendButton" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="-5dip"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Not Going" 
     android:id="@+id/declineButton" 
     android:layout_alignTop="@+id/attendButton" 
     android:layout_toRightOf="@+id/attendButton" 
     android:layout_toEndOf="@+id/attendButton" 
     android:layout_marginLeft="-7dip"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:text="EventDayOfWeek" 
     android:id="@+id/eventDayOfTheWeekTxt" 
     android:textColor="#000000" 
     android:singleLine="true" 
     android:layout_below="@+id/eventName" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:text="EventTime" 
     android:id="@+id/eventTimeTxt" 
     android:textColor="#000000" 
     android:layout_below="@+id/eventDayOfTheWeekTxt" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="New Button" 
     android:id="@+id/button2" 
     android:layout_below="@+id/attendButton" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

</RelativeLayout> 

が、それはlike this(the top one)になります。これが私の通知の作成です

何私はあなたに見て欲しい、残りの部分はnotificationsで、私の通知よりもどれだけ大きく見えますか?

通知サイズを希望のサイズに変更する方法はありますか?

あるいは、少なくとも画像内の他の通知の大きさに

私はnotificationの拡張サイズについては説明していませんが、デフォルトのサイズです。

答えて

0

テキストビュー(またはボタン)の間にスペースを提供する場合は、marginTop、marginBottom &のマージンを適用します。あなたが望む結果が得られるまで、異なる値で遊ぶことができます

+0

これは私が探しているものではありません...私は、テキストのビューとボタンを置くことができる通知自体のサイズを変更する必要があります...それらの間のスペースではありません。 – Jack

関連する問題