现在的位置: 首页 > 综合 > 正文

自定义对话框dialog的建立

2017年11月17日 ⁄ 综合 ⁄ 共 1054字 ⁄ 字号 评论关闭

 

自定义dialog的建立

 

如果你想自定义dialog的布局,你可以自己创建一个dialog布局。定义好之后,传递根View对象或者资源ID到setContextView(View)方法。

例如,如上图的dialog:

1-建立一个xml布局文件custom_dialog.xml;

view plaincopy to clipboardprint?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android
              android:id="@+id/layout_root" 
              android:orientation="horizontal" 
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent" 
              android:padding="10dp" 
              
    <ImageView android:id="@+id/image" 
               android:layout_width="wrap_content" 
               android:layout_height="fill_parent" 
               android:layout_marginRight="10dp" 
               />  
    <TextView android:id="@+id/text" 
              android:layout_width="wrap_content" 
              android:layout_height="fill_parent" 
              android:textColor="#FFF" 
              />  
</LinearLayout> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout_root"
              android:orientation="horizontal"
          

抱歉!评论已关闭.