2016-07-05 20 views
0

我已經知道我們在UrbanAirship站點(配置 - >應用內消息)中有一個配置部分,並且閱讀http://docs.urbanairship.com/platform/android.html#custom-style。但有了這個,我無法更改所有的應用內佈局。Urbanairship - 應用內消息定製

總之:

  1. 我如何更改按鈕樣式(適用邊界,改變只爲按鈕 背景顏色,顏色的文字按鈕...)?

    Base.Widget.UrbanAirship.InAppMessage.Banner.ActionButton

  2. 如何隱藏按鈕,通知描述之間的分隔?

    Base.Widget.UrbanAirship.InAppMessage.Banner.Divider

回答

2

佈局調整需要一點點的工作,但可以做到的。首先,你需要創建一個自定義InAppMessageFragment:

public class CustomInAppMessageFragment extends InAppMessageFragment { 
    @Override 
    public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { 
     if (getMessage() == null || getMessage().getAlert() == null) { 
      dismiss(false); 
      return null; 
     } 


     // Bind the in-app message to the layout. The fragment is attached to the content of the activity, 
     // so it has the full activity width and height to work with. 
     TextView view = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, container, false); 
     view.setText(getMessage().getAlert()); 


     return view; 
    } 
} 

然後設置在應用程序的消息管理器的片段工廠起飛後:

airship.getInAppMessageManager().setFragmentFactory(new InAppMessageFragmentFactory() { 
    @Override 
    public InAppMessageFragment createFragment(InAppMessage message) { 
     return new CustomInAppMessageFragment(); 
    } 
}); 

看看在source看如何-app消息片段的視圖通常被創建。