国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android自定義dialog 自下往上彈出的實例代碼

2019-10-21 21:41:44
字體:
供稿:網(wǎng)友

具體代碼如下所示:

package com.example.idmin.myapplication.wiget;import android.app.Dialog;import android.content.Context;import android.os.Bundle;import android.view.Gravity;import android.view.View;import android.view.WindowManager;import android.widget.TextView;import com.example.idmin.myapplication.R;import butterknife.BindView;import butterknife.ButterKnife;import butterknife.OnClick;public class BottomDialog extends Dialog {  @BindView(R.id.chang)  TextView chang;  @BindView(R.id.exite)  TextView exite;  @BindView(R.id.cancel)  TextView cancel;  private BottomDialogAlertListener listener;  private Object param;  private String text1;  private String text2;  private String cansleText;  public BottomDialog(Context context, BottomDialogAlertListener listener, Object param, String text1, String text2, String cansleText) {    super(context, R.style.dialog1);    this.listener = listener;    this.param = param;    this.text1 = text1;    this.text2 = text2;    this.cansleText = cansleText;  }  @Override  protected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.dialog_bottom);    ButterKnife.bind(this);    setCancelable(false);    setCanceledOnTouchOutside(false);    if (listener != null) {      listener.onDialogCreate(this, param);    }    setView();  }  private void setView() {    chang.setText(text1);    exite.setText(text2);    cancel.setText(cansleText);  }  @OnClick({R.id.chang, R.id.exite, R.id.cancel})  public void onViewClicked(View view) {    switch (view.getId()) {      case R.id.chang:        if (listener != null) {          listener.chenge(this,param);        }        break;      case R.id.exite:        if (listener != null) {          listener.excite(this,param);        }        break;      case R.id.cancel:        if (listener != null) {          listener.cancel(this,param);        }        break;    }  }  @Override  public void show() {    super.show();    /**     * 設(shè)置寬度全屏,要設(shè)置在show的后面     */    WindowManager.LayoutParams layoutParams = getWindow().getAttributes();    layoutParams.gravity = Gravity.BOTTOM;    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;    layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;    getWindow().getDecorView().setPadding(0, 0, 0, 0);    getWindow().setAttributes(layoutParams);  }} <!-- 自定義dialog樣式 --><style name="dialog1" parent="@android:style/Theme.Dialog">  <item name="android:windowFrame">@null</item>  <item name="android:windowIsFloating">true</item>  <item name="android:windowIsTranslucent">false</item>  <item name="android:windowNoTitle">true</item>  <item name="android:background">@android:color/transparent</item>  <item name="android:windowBackground">@android:color/transparent</item>  <item name="android:backgroundDimEnabled">true</item>  <item name="android:layout_width">match_parent</item>  <!-- 進入和退出的動畫 -->  <item name="android:windowAnimationStyle">@style/BottomDialogAnimation</item></style> <!-- 進入和退出的動畫 --><style name="BottomDialogAnimation">  <!--進入 -->  <item name="android:windowEnterAnimation">@anim/dialog_enter_from_bottom</item>  <!--退出-->  <item name="android:windowExitAnimation">@anim/dialog_exit_to_bottom</item></style> <!--dialog_enter_from_bottom --><?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android">  <translate    android:duration="200"    android:fromYDelta="100%p"    android:toYDelta="0"></translate></set> <!--dialog_exit_to_bottom --><?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android">  <translate    android:duration="200"    android:fromYDelta="0"    android:toYDelta="100%p"></translate></set>

總結(jié)

以上所述是小編給大家介紹的Android自定義dialog 自下往上彈出的實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對VEVB武林網(wǎng)網(wǎng)站的支持!


注:相關(guān)教程知識閱讀請移步到Android開發(fā)頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 兴义市| 察隅县| 景德镇市| 大名县| 梁山县| 梧州市| 郎溪县| 洱源县| 香格里拉县| 靖宇县| 谢通门县| 象山县| 遵义市| 厦门市| 师宗县| 延庆县| 玉屏| 新乐市| 波密县| 繁昌县| 华池县| 伽师县| 北碚区| 石楼县| 河北省| 大庆市| 秭归县| 屏边| 瓦房店市| 桃源县| 裕民县| 东城区| 保定市| 弥勒县| 贵定县| 当雄县| 临西县| 济源市| 荥经县| 无锡市| 徐汇区|