• <kbd id="qyk40"></kbd>
  • <strike id="qyk40"></strike><samp id="qyk40"><pre id="qyk40"></pre></samp>

    在網(wǎng)上找了很多關(guān)于dialog的自定義樣式的問題,還有很多人寫得比較復(fù)雜,需要改動style什么的,或者是自定義dialog搞得很復(fù)雜,我最后還是找到了方法來實現(xiàn)。參考原文地址:http://jy0329.blog.163.com/blog/static/14746600220132204035120/

    下面是我的dialog布局xml文件:


    [mw_shl_code=java,true]

        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:layout_margin="50dp">
        
       
            android:id="@+id/rl_dialog_content"
            android:layout_width="fill_parent"
            android:layout_height="200dp"
            android:background="@drawable/alertdialog_bg">
                
                    android:id="@+id/dialog_text"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="現(xiàn)在就打電話給客服:arjinmc"           
                    android:layout_marginTop="50dp"     
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"
                    android:maxLines="5"
                    android:gravity="center"
                    />        
                    
                
                    android:id="@+id/ll_buttons"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:layout_alignParentBottom="true"
                    android:layout_margin="30dp">
                    
                    
                   
                     android:id="@+id/dialog_cancel"
                     android:text="@string/alert_cancel"
                     android:background="@drawable/btn_long_white"
                     style="@style/dialog_button"
                     android:layout_weight="1"
                     android:textColor="@color/tabs_font"
                     />
                   
                     android:id="@+id/dialog_ok"
                     android:text="@string/alert_ok"
                     android:background="@drawable/btn_long_red"
                     style="@style/dialog_button"
                     android:layout_weight="1"
                     android:layout_marginLeft="5dp"/>
                    
                
       

       
            android:id="@+id/dialog_close"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/alertdialog_close"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="20dp"
           />   
        


    [/mw_shl_code]
     

    效果如圖:

     

     

     

    在代碼中需要這樣寫就可以了:

    [mw_shl_code=java,true]//布局文件轉(zhuǎn)換為view對象
                      LayoutInflater inflaterDl = LayoutInflater.from(this);
                      RelativeLayout layout = (RelativeLayout)inflaterDl.inflate(R.layout.layout_dialog, null );
                      
                      //對話框
                      final Dialog dialog = new AlertDialog.Builder(SettingActivity.this).create();
                      dialog.show();
                      dialog.getWindow().setContentView(layout);
                      
                      
                      //取消按鈕
                      Button btnCancel = (Button) layout.findViewById(R.id.dialog_cancel);
                      btnCancel.setOnClickListener(new OnClickListener() {
                            
                            @Override
                            public void onClick(View v) {
                                    Toast.makeText(getApplicationContext(), "cancel", Toast.LENGTH_SHORT).show();                                
                            }
                      });
                      
                      
                      //確定按鈕
                      Button btnOK = (Button) layout.findViewById(R.id.dialog_ok);
                      btnOK.setOnClickListener(new OnClickListener() {
                            
                            @Override
                            public void onClick(View v) {
                                    Toast.makeText(getApplicationContext(), "ok", Toast.LENGTH_SHORT).show();                                
                            }
                      });
                      
                      
                      //關(guān)閉按鈕
                      ImageButton btnClose = (ImageButton) layout.findViewById(R.id.dialog_close);
                      btnClose.setOnClickListener(new OnClickListener() {
                            
                            @Override
                            public void onClick(View v) {
                                    dialog.dismiss();                                
                            }
                      });[/mw_shl_code]

     

     

    非常easy!自己動手吧。

     

    穩(wěn)定

    產(chǎn)品高可用性高并發(fā)

    貼心

    項目群及時溝通

    專業(yè)

    產(chǎn)品經(jīng)理1v1支持

    快速

    MVP模式小步快跑

    承諾

    我們選擇聲譽

    堅持

    10年專注高端品質(zhì)開發(fā)
    • 返回頂部
    国产精品毛多多水多| 免费99精品国产自在现线| 国产在线精品国自产拍影院| 国产成人无码综合亚洲日韩| 国产精品高清在线观看93| 久久精品无码一区二区三区免费| 91精品国产免费入口| 久久精品99国产精品日本| assbbwbbwbbwbbwbw精品| 国产精品主播一区二区| 国产99精品一区二区三区免费| 任我爽精品视频在线播放| 日韩精品视频观看| 亚洲精品无码日韩国产不卡av | 日韩精品乱码AV一区二区| 国产精品jvid在线观看| 欧洲精品码一区二区三区| 国产精品欧美成人| 精品国产粉嫩内射白浆内射双马尾| 久久夜色精品国产噜噜亚洲a| 国产精品视频免费| 国产成人yy精品1024在线| 国产精品一区在线播放| 精品国产一二三区在线影院| 国产精品手机在线| 无码人妻精品中文字幕免费东京热| 国产精品色拉拉免费看| 2020国产精品| 亚洲精品GV天堂无码男同| 国产欧美一区二区精品仙草咪| 青草青草久热精品观看| 日韩精品人妻系列无码av东京| 国产精品成人久久久久| 国产精品久久国产精品99| 国产日韩精品一区二区三区在线| 日韩精品一区二区三区色欲AV| 日韩视频一区二区| 精品乱码一区内射人妻无码| 亚洲精品无码av天堂| 久久久WWW免费人成精品| 亚洲午夜国产精品无码老牛影视|