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

Android使用Dialog風(fēng)格彈出框的Activity

 更新時(shí)間:2020年04月18日 16:03:27   作者:qq_20785431  
這篇文章主要為大家詳細(xì)介紹了Android使用Dialog風(fēng)格彈出框的Activity,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

在Android中經(jīng)常會(huì)遇到需要使用Dialog風(fēng)格彈出框的activity,首先我們可能會(huì)首先想到的是在XML布局文件中設(shè)置android:layout_height="wrap_content"屬性,讓activity的高度自適應(yīng),顯然這還不行,我們還需要為其DialogActivity設(shè)置自定義一個(gè)樣式 

<style name="dialogstyle">
 <!--設(shè)置dialog的背景-->
 <item name="android:windowBackground">@android:color/transparent</item>
 <!--設(shè)置Dialog的windowFrame框?yàn)闊o-->
 <item name="android:windowFrame">@null</item>
 <!--設(shè)置無標(biāo)題-->
 <item name="android:windowNoTitle">true</item>
 <!--是否浮現(xiàn)在activity之上-->
 <item name="android:windowIsFloating">true</item>
 <!--是否半透明-->
 <item name="android:windowIsTranslucent">true</item>
 <!--設(shè)置窗口內(nèi)容不覆蓋-->
 <item name="android:windowContentOverlay">@null</item>
 <!--設(shè)置動(dòng)畫,在這里使用讓它繼承系統(tǒng)的Animation.Dialog-->
 <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
 <!--背景是否模糊顯示-->
 <item name="android:backgroundDimEnabled">true</item>
 </style>

然后在AndroidManifest.xml中設(shè)置DialogActivity的樣式為我們自定義的dialogstyle

如下是布局的代碼 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="@color/white"
 android:orientation="vertical">

 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="65dp"
 android:orientation="horizontal"
 android:paddingLeft="@dimen/acitvity_margin"
 android:paddingRight="@dimen/acitvity_margin">

 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="match_parent"
 android:layout_weight="1"
 android:orientation="horizontal">

 <TextView
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:gravity="center"
 android:text="上班時(shí)間:"
 android:textColor="@color/grey"
 android:textSize="@dimen/size_text_medium" />

 <Button
 android:id="@+id/tv_signin_time"
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:background="@color/white"
 android:gravity="center"
 android:text="9:00"
 android:textColor="@color/grey"
 android:textSize="@dimen/size_text_medium" />
 </LinearLayout>

 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="match_parent"
 android:layout_weight="1"
 android:orientation="horizontal">

 <TextView
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:gravity="center"
 android:text="下班時(shí)間:"
 android:textColor="@color/grey"
 android:textSize="@dimen/size_text_medium" />

 <Button
 android:id="@+id/tv_signout_time"
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:background="@color/white"
 android:gravity="center"
 android:text="18:00"
 android:textColor="@color/grey"
 android:textSize="@dimen/size_text_medium" />
 </LinearLayout>
 </LinearLayout>

 <RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="65dp"
 android:paddingLeft="@dimen/acitvity_margin"
 android:paddingRight="@dimen/acitvity_margin">

 <TextView
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:layout_alignParentLeft="true"
 android:gravity="center"
 android:text="公司位置:"
 android:textColor="@color/grey"
 android:textSize="@dimen/size_text_medium" />

 <EditText
 android:id="@+id/et_address"
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:layout_marginLeft="2dp"
 android:layout_toRightOf="@+id/tv_address"
 android:background="@color/white"
 android:hint="請輸入公司位置"
 android:singleLine="true"
 android:textSize="@dimen/size_text_small" />

 <TextView
 android:id="@+id/tv_location"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentRight="true"
 android:layout_centerInParent="true"
 android:gravity="center"
 android:padding="5dp"
 android:text="重新定位"
 android:textColor="@color/blue"
 android:textSize="@dimen/size_text_medium" />
 </RelativeLayout>

 <RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="65dp"
 android:paddingLeft="@dimen/acitvity_margin"
 android:paddingRight="@dimen/acitvity_margin">

 <TextView
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:layout_alignParentLeft="true"
 android:gravity="center"
 android:text="設(shè)置管理員:"
 android:textColor="@color/grey"
 android:textSize="@dimen/size_text_medium" />

 <ImageView
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:layout_alignParentRight="true"
 android:gravity="center"
 android:src="@mipmap/icon_toright" />
 </RelativeLayout>
</LinearLayout> 

接下來我們再看一下效果圖是不是我們想要的呢

源碼下載:http://xiazai.jb51.net/201609/yuanma/DialogActivity(jb51.net).rar

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

相關(guān)文章

最新評論

安龙县| 富蕴县| 新野县| 揭阳市| 湖北省| 安吉县| 舟山市| 西青区| 仁寿县| 多伦县| 龙山县| 房产| 福安市| 满城县| 开封县| 白玉县| 积石山| 延川县| 望奎县| 佛山市| 平果县| 磐石市| 新余市| 莆田市| 鹤岗市| 喀喇沁旗| 彰化县| 响水县| 曲沃县| 河间市| 集贤县| 大同县| 丹巴县| 景德镇市| 巴彦县| 和林格尔县| 青河县| 鄄城县| 渭南市| 东山县| 镇坪县|