Urbanairship - 应用内消息定制

时间:2016-07-05 14:41:17

标签: android urbanairship.com

我已经知道我们在UrbanAirship网站(配置 - >应用程序内消息)中有一个配置部分并阅读http://docs.urbanairship.com/platform/android.html#custom-style。但有了这个,我无法改变所有的应用程序内布局。

总结:

  1. 如何更改按钮的样式(应用边框,更改 背景颜色只为按钮,颜色为文本按钮...)?

    Base.Widget.UrbanAirship.InAppMessage.Banner.ActionButton

  2. 如何在按钮和通知说明之间隐藏分隔符?

    Base.Widget.UrbanAirship.InAppMessage.Banner.Divider

1 个答案:

答案 0 :(得分: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;  
    }  
}

然后在takeOff:

之后在应用内消息管理器中设置片段工厂
airship.getInAppMessageManager().setFragmentFactory(new InAppMessageFragmentFactory() {  
    @Override  
    public InAppMessageFragment createFragment(InAppMessage message) {  
        return new CustomInAppMessageFragment();  
    }  
});

查看source,了解应用内消息片段的视图是如何正常创建的。