最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android BottomSheetDialog實(shí)現(xiàn)底部對(duì)話框的示例

 更新時(shí)間:2018年06月14日 10:55:13   作者:coderguoy  
這篇文章主要介紹了Android BottomSheetDialog實(shí)現(xiàn)底部對(duì)話框的示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

Android 6.0新控件 BottomSheetDialog | 底部對(duì)話框 介紹及使用詳情

extends AppCompatDialog

Base class for Dialogs styled as a bottom sheet

基于Dialog樣式的一個(gè)底部對(duì)話框

先看看效果

對(duì)于彈出的內(nèi)容完全由自己來(lái)掌控,想實(shí)現(xiàn)什么樣子就實(shí)現(xiàn)什么樣子,很靈活

使用方法

BottomSheetDialog來(lái)自design兼容包,使用需要添加依賴。android studio 添加依賴如下:

dependencies {
  compile ‘com.android.support:design:23.2.0+‘
}

1.XML中添加布局文件

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="2">

    <RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1">

      <ImageView
        android:id="@+id/image_man"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?android:selectableItemBackground"
        android:gravity="center"
        android:padding="10dp"
        android:src="@drawable/man"/>
    </RelativeLayout>

    <RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1">

      <ImageView
        android:id="@+id/image_women"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?android:selectableItemBackground"
        android:gravity="center"
        android:padding="10dp"
        android:src="@drawable/women"/>
    </RelativeLayout>

  </LinearLayout>

2.在代碼中使用

 @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_bottom_sheet_dialog);
    showContentView();
    bindingView.bottomsheet.textviewTitle.setText("BottomSheetDialog");
    bindingView.bottomsheet.toolbarBack.setOnClickListener(this);
    bindingView.btnBsd1.setOnClickListener(this);
    initView();
  }

  private void initView() {
    View view = View.inflate(this, R.layout.bottom_dialog, null);
    ImageView man = (ImageView) view.findViewById(R.id.image_man);
    ImageView women = (ImageView) view.findViewById(R.id.image_women);
    man.setOnClickListener(this);
    women.setOnClickListener(this);

    bsd1 = new BottomSheetDialog(this);
    bsd1.setContentView(view);

  }

  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.toolbar_back:
        finish();
        break;
      case R.id.btn_bsd1:
        bsd1.show();
        break;
      case R.id.image_man:
        ToastUtil.show("男");
        bsd1.dismiss();
        break;
      case R.id.image_women:
        ToastUtil.show("女");
        bsd1.dismiss();
        break;
    }
  }

OK,這就完成了如效果圖上的效果,可以自己嘗試一下,下面貼上一些可以自己定制需求常用的方法

setCancelable(boolean cancelable) | 設(shè)置此對(duì)話框是否取消與BACK關(guān)聯(lián)

setCanceledOnTouchOutside | 當(dāng)設(shè)置窗口的邊界之外觸及這個(gè)對(duì)話框是否被取消

官方API

完整代碼點(diǎn)我下載GitHub

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

义马市| 新巴尔虎右旗| 韩城市| 张掖市| 阿拉善盟| 东阳市| 无极县| 邻水| 隆子县| 论坛| 武邑县| 扬州市| 厦门市| 登封市| 姚安县| 岳阳县| 云梦县| 通许县| 东辽县| 东丽区| 江孜县| 桃源县| 辽阳县| 沙湾县| 澄城县| 东山县| 肥西县| 且末县| 泸水县| 梁平县| 卓资县| 津南区| 上虞市| 常宁市| 五峰| 伊川县| 赤峰市| 息烽县| 遵化市| 进贤县| 新野县|