After the Android integration Friend League share, want to customize the share panel to look over

Source: Internet
Author: User

First case

First upload a default friend league share

It looks good, but there's always a reason for that, and we need to make some changes to the default effect.

The second case

If you want to make the following effect:

Or the effect of this:

In short, the above effect is always based on the default (and the original control based on the change, change color, background, background color, etc. some basic changes),
If you really meet this demand is very simple: you can directly login to the league's development document is very detailed introduction, very simple
Here are some of the following:


Well, it's over.
You can go straight in and see.

Chapter III Situation

In the first two cases, if you have not yet met your needs, then our focus today. You want to fully customize.
For example, our project needs to achieve the following effect

I saw the Friend League development document, can change the above TextView color, but I want to add a background image behind it, it is obviously not enough to meet my needs, friends of the Union did not provide me
Methods and interfaces. What do we do?

The following is implemented in a dialog-custom way

(1) Define the XML for the view

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" wrap_content "android:background=" @color/white "android:orientation=" vertical "> <relativelayout android:layout_width=" match_parent "Android:layout_ height= "@dimen/dip_80" android:background= "@drawable/fxyl_tk_bg" > <textview android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:textcolor= "@color/whites" android:t          ext= "Your Invite code: 123456" android:layout_alignparentbottom= "true" android:layout_marginbottom= "@dimen/dip_8" Android:layout_centerhorizontal= "true"/> </RelativeLayout> <linearlayout Android:layout_marg intop= "@dimen/dip_20" android:layout_width= "fill_parent" android:layout_height= "Wrap_content" Android     : orientation= "Horizontal" >   <relativelayout android:id= "@+id/view_share_weixin" android:layout_width= "0DP" Android oid:layout_height= "Wrap_content" android:layout_weight= "1" > <imageview android:id=            "@+id/share_icon" android:layout_width= "wrap_content" android:layout_height= "Wrap_content"                Android:layout_centerhorizontal= "true" android:src= "@drawable/wxx"/> <textview Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" Android:layout_b elow= "@id/share_icon" android:layout_centerhorizontal= "true" android:layout_margintop= "@dime N/dip_13 "android:text=" "/> </RelativeLayout> <relativelayout Android            : id= "@+id/view_share_weixinfriend" android:layout_width= "0DP" android:layout_height= "Wrap_content" Android:layout_weight= "1" > <imageview android:id= "@+id/share_icon2" android:layout_width                = "Wrap_content" android:layout_height= "Wrap_content" android:layout_centerhorizontal= "true" android:src= "@drawable/pyqx"/> <textview android:layout_width= "Wrap_conten                T "android:layout_height=" wrap_content "android:layout_below=" @id/share_icon2 " Android:layout_centerhorizontal= "true" android:layout_margintop= "@dimen/dip_13" Android:te            xt= "Friends Circle"/> </RelativeLayout> <relativelayout android:id= "@+id/view_share_qq"            Android:layout_width= "0DP" android:layout_height= "Wrap_content" android:layout_weight= "1" >                <imageview android:id= "@+id/share_icon3" android:layout_width= "Wrap_content" Android:layout_height= "Wrap_content" android:layout_centerhorizontal= "true" android:src= "@drawable/qqx" /> <textview android:layout_width= "wrap_content" android:layout_height= "WR                Ap_content "android:layout_below=" @id/share_icon3 "android:layout_centerhorizontal=" true " android:layout_margintop= "@dimen/dip_13" android:text= "QQ"/> </relativelayout&gt        ; <relativelayout android:id= "@+id/share_qqzone" android:layout_width= "0DP" Android:layo ut_height= "Wrap_content" android:layout_weight= "1" > <imageview android:id= "@+i                D/share_icon4 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "                Android:layout_centerhorizontal= "true" android:src= "@drawable/kjx"/> <textview Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" Android:layout_bel ow= "@id/share_icon4" android:layout_centerhorizontal= "true" android:layout_margintop= "@dimen        /dip_13 "android:text=" QQ space "/> </RelativeLayout> </LinearLayout> <textview android:layout_margintop= "@dimen/dip_10" android:layout_marginbottom= "@dimen/dip_10" android:id= "@+id /share_cancel_btn "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:l Ayout_gravity= "Center_horizontal" android:text= "Cancel"/></linearlayout>

(2) Inflater A custom view in dialog

 private void Showsharedialog () {View view = Layoutinflater.from (Acountrytour.this). Inflate (r.layout.customshare_l        Ayout, NULL);        Set style controls the margin problem caused by the default Dialog final Dialog Dialog = new Dialog (this, r.style.common_dialog);        Dialog.setcontentview (view);        Dialog.show (); Monitor View.onclicklistener listener = new View.onclicklistener () {@Override public void Oncl Ick (View v) {switch (V.getid ()) {case R.id.view_share_weixin:/ /share to share (Share_media.                        Weixin);                    Break Case R.id.view_share_weixinfriend://share to Friends Circle share (Share_media.                        Weixin_circle);                    Break Case R.ID.VIEW_SHARE_QQ://Share to QQ share (Share_media.                        QQ);                    Break Case R.id.share_qqzoNE://share to QQ space share (Share_media.                        QZONE);                    Break                Case R.ID.SHARE_CANCEL_BTN://Cancel break;            } Dialog.dismiss ();        }        };        ViewGroup mviewweixin = (viewgroup) View.findviewbyid (r.id.view_share_weixin);        ViewGroup mviewpengyou = (viewgroup) View.findviewbyid (r.id.view_share_weixinfriend);        ViewGroup mviewqq= (ViewGroup) View.findviewbyid (R.ID.VIEW_SHARE_QQ);        ViewGroup Mviewqqzone = (viewgroup) View.findviewbyid (R.id.share_qqzone);        TextView Mbtncancel = (TextView) View.findviewbyid (R.ID.SHARE_CANCEL_BTN);        Mviewweixin.setonclicklistener (listener);        Mviewpengyou.setonclicklistener (listener);        Mviewqq.setonclicklistener (listener);        Mviewqqzone.setonclicklistener (listener);        Mbtncancel.setonclicklistener (listener); Set the relevant location, be sure to wind after show ()ow window = Dialog.getwindow ();        Window.getdecorview (). setpadding (0, 0, 0, 0);        Windowmanager.layoutparams params = Window.getattributes ();        Params.width = ViewGroup.LayoutParams.MATCH_PARENT;        params.gravity = Gravity.bottom;    Window.setattributes (params); }

Perfect for the effect

Attention:

1. Define the location of the dialog window:

2. The bottom alignment is filled with screen properties and the margin is found, and the dialog style needs to be redefined, with padiing in the style by default.

<!-- 默认的style -->     <style name="common_dialog" parent="@android:style/Theme.Dialog">         <item name="android:windowBackground">@android:color/transparent</item>         <item name="android:windowNoTitle">true</item>     </style>  

Thank you for coming. Android June with you. Please leave a message if you need a complete code.

After the Android integration Friend League share, want to customize the share panel to look over

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.