亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 系統 > Android > 正文

Android實現微信右側頂部下拉對話框

2019-10-21 21:32:09
字體:
來源:轉載
供稿:網友

我們使用微信都知道,其右側頂部有一個下拉對話框,我們可以執行添加好友,掃一掃等功能,今天我們就來模仿實現一下這個功能(實現的方式有很多種,我今天只說一種借助透明主題Activity的方式實現;如果有興趣還可以移步至仿淘寶底部導航欄);本篇的實現的效果如下:

Android,微信,下拉,對話框

下面就來說一說實現的思路重要

第一步:創建彈出對話框布局

<?xml version="1.0" encoding="UTF-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" >  <RelativeLayout  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:layout_marginTop="45dp"  android:layout_marginRight="20dp">   <LinearLayout   android:id="@+id/id_pop_dialog_layout"   android:layout_width="@dimen/pop_list_width"   android:layout_height="wrap_content"   android:layout_alignParentRight="true"   android:layout_alignParentTop="true"   android:background="@drawable/pop_item_normal"   android:orientation="vertical" >    <LinearLayout    android:id="@+id/upload_record_layout"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:layout_marginLeft="5dp"    android:layout_marginRight="5dp"    android:layout_marginTop="5dp"    android:background="@drawable/pop_list_selector" >     <ImageView     android:id="@+id/id_imageView1"     android:layout_width="@dimen/pop_dialog_icon_size"     android:layout_height="@dimen/pop_dialog_icon_size"     android:layout_gravity="center_vertical"     android:layout_marginLeft="8dp"     android:src="@drawable/upload_icon_record" />     <TextView     android:layout_width="@dimen/pop_list_width"     android:layout_height="wrap_content"     android:padding="8dp"     android:text="@string/uploadRecord"      android:layout_gravity="center_vertical"     android:textColor="#fff"     android:textSize="16sp" />   </LinearLayout>    <ImageView    android:id="@+id/id_imageView5"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:src="@drawable/pop_line" />    <LinearLayout    android:id="@+id/register_record_layout"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:layout_marginLeft="5dp"    android:layout_marginRight="5dp"    android:background="@drawable/pop_list_selector" >     <ImageView     android:id="@+id/id_imageView2"     android:layout_width="@dimen/pop_dialog_icon_size"     android:layout_height="@dimen/pop_dialog_icon_size"     android:layout_gravity="center_vertical"     android:layout_marginLeft="8dp"     android:src="@drawable/register_icon_record" />     <TextView     android:layout_width="@dimen/pop_list_width"     android:layout_height="wrap_content"     android:padding="8dp"     android:text="@string/registerRecord"      android:layout_gravity="center_vertical"     android:textColor="#fff"     android:textSize="16sp" />   </LinearLayout>    <ImageView    android:id="@+id/id_imageView7"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:src="@drawable/pop_line" />    <LinearLayout    android:id="@+id/new_massage_layout"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:layout_marginLeft="5dp"    android:layout_marginRight="5dp"    android:background="@drawable/pop_list_selector" >     <ImageView     android:id="@+id/id_imageView3"     android:layout_width="@dimen/pop_dialog_icon_size"     android:layout_height="@dimen/pop_dialog_icon_size"     android:layout_gravity="center_vertical"     android:layout_marginLeft="8dp"     android:src="@drawable/message_icon_tip" />     <TextView     android:id="@+id/new_message"     android:layout_width="@dimen/pop_list_width"     android:layout_height="wrap_content"     android:padding="8dp"     android:text="@string/defaultMessage"     android:layout_gravity="center_vertical"     android:textColor="#fff"     android:textSize="16sp" />   </LinearLayout>    <ImageView    android:id="@+id/id_imageView6"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:src="@drawable/pop_line" />   </LinearLayout> </RelativeLayout> </RelativeLayout>

第二步:創建一個用于顯示該對話框布局Activity

package com.hfut.popdialogtest; import android.app.Activity;import android.os.Bundle;import android.view.MotionEvent;import android.view.View;import android.view.View.OnClickListener;import android.view.Window;import android.widget.LinearLayout; /** * @author why * @date 2018-10-3 */public class MyDialogActivity extends Activity implements OnClickListener{  private LinearLayout uploadRecord; private LinearLayout registerRecord; private LinearLayout newMessage;  @Override protected void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  requestWindowFeature(Window.FEATURE_NO_TITLE);  setContentView(R.layout.pop_dialog);   if(getActionBar()!=null){   getActionBar().hide();  }  CommonTools.setNavbarVisibility(this);  initView(); }   private void initView(){  uploadRecord = findViewById(R.id.upload_record_layout);  registerRecord = findViewById(R.id.register_record_layout);  newMessage = findViewById(R.id.new_massage_layout);   uploadRecord.setOnClickListener(this);  registerRecord.setOnClickListener(this);  newMessage.setOnClickListener(this); }  @Override public boolean onTouchEvent(MotionEvent event){  finish();  return true; }  @Override public void onClick(View v) {  switch (v.getId()){   case R.id.upload_record_layout:   SharedData.resultID=1;   break;   case R.id.register_record_layout:   SharedData.resultID=2;   break;   case R.id.new_massage_layout:   SharedData.resultID=3;   break;   default:   SharedData.resultID=0;   break;  }  this.finish(); }}

第三步:創建一個主界面
MainActivity.java代碼:

package com.hfut.popdialogtest; import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.TextView; /** * @author why * @date 2018-10-3 9:35:35 */public class MainActivity extends AppCompatActivity {  TextView resultShow;  @Override protected void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setContentView(R.layout.activity_main);  resultShow = findViewById(R.id.show_choosen_result);   if(getActionBar()!=null){   getActionBar().hide();  }  CommonTools.setNavbarVisibility(this); }   @Override protected void onResume() {  switch (SharedData.resultID) {   case 0:    resultShow.setText("默認顯示");    break;   case 1:    resultShow.setText(getResources().getString(R.string.uploadRecord));    break;   case 2:    resultShow.setText(getResources().getString(R.string.registerRecord));    break;   case 3:    resultShow.setText(getResources().getString(R.string.defaultMessage));    break;   default:    resultShow.setText("默認顯示");    break;   }  super.onResume(); }  public void openPopDialog(View view) {  Intent intent = new Intent(this, PopDialogActivity.class);  startActivity(intent); }}

activity_main.xml代碼:

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.hfut.popdialogtest.MainActivity">  <ImageView  android:onClick="openPopDialog"  android:id="@+id/pop_dialog_icon"  app:layout_constraintRight_toRightOf="parent"  android:layout_marginRight="10dp"  app:layout_constraintTop_toTopOf="parent"  android:layout_marginTop="5dp"  android:background="@drawable/message_tip"  android:layout_width="50dp"  android:layout_height="50dp" />  <TextView  android:gravity="center"  android:textColor="@color/colorAccent"  android:textSize="30sp"  android:id="@+id/show_choosen_result"  app:layout_constraintTop_toBottomOf="@id/pop_dialog_icon"  android:layout_marginTop="50dp"  android:layout_width="match_parent"  android:layout_height="match_parent" /> </android.support.constraint.ConstraintLayout>

第四步:設置對話框Activity主題為透明主題
AndroidManifest.xml文件代碼:

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hfut.popdialogtest">  <application  android:allowBackup="true"  android:icon="@mipmap/ic_launcher"  android:label="@string/app_name"  android:roundIcon="@mipmap/ic_launcher_round"  android:supportsRtl="true"  android:theme="@style/AppTheme">  <activity android:name=".MainActivity">   <intent-filter>    <action android:name="android.intent.action.MAIN" />     <category android:name="android.intent.category.LAUNCHER" />   </intent-filter>  </activity>  <activity android:name=".MyDialogActivity" android:theme="@android:style/Theme.Translucent" /> </application> </manifest>

第五步:其他輔助代碼
CommonTools.java代碼:

package com.hfut.popdialogtest; import android.app.Activity;import android.view.View; /** * author:why * created on: 2018/9/11 13:34 * description: */public class CommonTools {  /**  * to controll the visibility of the Activity's navigator bar  * @param activity  */ public static void setNavbarVisibility(Activity activity) {  View decorView = activity.getWindow().getDecorView();  decorView.setSystemUiVisibility(    View.SYSTEM_UI_FLAG_LAYOUT_STABLE      | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN      | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION      | View.SYSTEM_UI_FLAG_FULLSCREEN      | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } }

Values目錄下的dimens.xml代碼:

<?xml version="1.0" encoding="utf-8"?><resources> <dimen name="pop_list_width">160dp</dimen> <dimen name="pop_dialog_icon_size">60dp</dimen> <dimen name="pop_dialog_icon_tip_size">40dp</dimen></resources>

Values目錄下的strings.xml代碼:

<resources> <string name="app_name">仿微信右側頂部下拉彈出測試</string>  <string name="uploadRecord">上傳記錄</string> <string name="registerRecord">注冊記錄</string> <string name="defaultMessage">消息提示</string> </resources>

其他資源文件就不添加了。我們總結一下其實就是這樣的步驟:

  • 點擊主Activity的彈窗對話框圖標,打開一個新的透明的Acitivity
  • 在新的Activity中做完邏輯處理把結果存放在主Activity可訪問的數據域,然后finish自己
  • 主Activity再次可交互,并在onResume中實現對處理結果分析和處理,比如修改主Activity UI; 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
国产欧美久久久久久| 欧亚精品在线观看| 欧美另类99xxxxx| 秋霞av国产精品一区| 疯狂欧美牲乱大交777| 成人免费激情视频| 欧美激情国内偷拍| 亚洲天堂av在线免费| 性欧美长视频免费观看不卡| 国产精品91久久| 成人信息集中地欧美| 日韩中文av在线| 成人亚洲激情网| 国产精品嫩草影院一区二区| 亚洲最大成人网色| 亚洲第一区在线观看| 久久人人爽亚洲精品天堂| 亚洲久久久久久久久久久| 成人精品久久av网站| 97av视频在线| 成人一区二区电影| 精品国内自产拍在线观看| 欧美大片在线影院| 亚洲一区二区精品| 成人黄色大片在线免费观看| 久久久成人av| 欧美亚洲免费电影| 欧美精品aaa| 精品欧美一区二区三区| 国产做受高潮69| 大胆人体色综合| 国产精品入口福利| 国产视频999| 日韩在线一区二区三区免费视频| 日韩毛片在线看| 亚洲一区二区免费| 国产美女精品视频免费观看| 国产欧美一区二区三区久久| 亚洲一区二区在线| 中文国产成人精品久久一| 亚洲成人黄色网| 91伊人影院在线播放| 日本成人激情视频| 秋霞午夜一区二区| 日韩av在线免播放器| 欧美小视频在线| 亚洲欧洲日本专区| 国产成人精品视频在线观看| 欧美在线观看网站| 久久精品国产欧美激情| 欧美色欧美亚洲高清在线视频| 亚州国产精品久久久| 欧美电影免费观看高清| 欧美老少配视频| 中文字幕久久亚洲| 欧美老少配视频| 欧美精品久久久久久久久久| 岛国av一区二区在线在线观看| 国产日韩亚洲欧美| 久久久国产在线视频| 亚洲精选在线观看| 欧美性猛交xxxx乱大交极品| 在线成人激情黄色| 久久精品视频亚洲| 97视频com| 日韩经典中文字幕在线观看| 国产精品视频大全| 日韩av最新在线| 欧美一级成年大片在线观看| 国产精品久久久久久av下载红粉| 北条麻妃在线一区二区| 亚洲综合小说区| 91chinesevideo永久地址| 欧美精品精品精品精品免费| 欧美精品福利视频| 国产成人欧美在线观看| 日本午夜人人精品| 精品无人区太爽高潮在线播放| 一区二区三区www| 精品久久久久久国产| 国产福利精品在线| 亚洲视频日韩精品| 精品国产一区av| 日韩视频在线观看免费| 欧美性感美女h网站在线观看免费| 欧美成人精品一区二区| 精品中文字幕在线| 亚洲国语精品自产拍在线观看| 在线精品视频视频中文字幕| 一本大道亚洲视频| 国产精品美女www| 国产一区二区三区视频在线观看| 国产偷国产偷亚洲清高网站| 欧美精品电影免费在线观看| 91精品国产高清久久久久久91| 亚洲另类激情图| 精品国产91久久久久久| 精品福利一区二区| 亚洲18私人小影院| 成人精品视频在线| 亚洲黄色www网站| 91精品久久久久久| 亚洲国产精品一区二区久| 亚洲伊人一本大道中文字幕| 成人福利免费观看| 国产成人精品免高潮费视频| 日本最新高清不卡中文字幕| 欧美在线视频免费播放| 成人精品网站在线观看| 国模精品系列视频| 亚洲一区二区中文| 亚洲精品网站在线播放gif| 国产精品视频久久久| 欧美精品激情blacked18| 久久人人爽人人爽人人片亚洲| 庆余年2免费日韩剧观看大牛| 一个人www欧美| 日韩中文视频免费在线观看| 亚洲天堂网在线观看| 日韩免费在线视频| 欧美激情奇米色| 久久亚洲精品一区| 亚洲免费伊人电影在线观看av| 日韩av电影在线播放| 欧美日韩午夜剧场| 色先锋久久影院av| 欧美性少妇18aaaa视频| 精品视频偷偷看在线观看| 欧美多人乱p欧美4p久久| 国产精品成人av性教育| 久久久最新网址| 国产精品av在线播放| 中文字幕av一区中文字幕天堂| 久久影院模特热| 视频直播国产精品| 日韩免费av一区二区| 成人精品久久久| 亚洲视频999| 国产精品jvid在线观看蜜臀| 国产欧美日韩中文字幕在线| 亚洲最大av网| 欧美日韩在线观看视频小说| 欧美高跟鞋交xxxxhd| 久久五月情影视| 国产亚洲欧美视频| 国产午夜精品全部视频在线播放| 欧美国产日韩一区二区| 欧美激情精品久久久久久免费印度| 成人黄色影片在线| 精品自拍视频在线观看| 欧美日韩一区二区三区在线免费观看| 亚洲欧美激情另类校园| 国产精品女人久久久久久| 国产成人久久久精品一区| 亚洲一区二区三区xxx视频| 久久精品国产亚洲| 亚洲v日韩v综合v精品v| 91精品视频播放| 欧美性做爰毛片| 欧美激情精品久久久久久| 欧美精品18videosex性欧美| 中文字幕在线看视频国产欧美在线看完整| 亚洲自拍偷拍色片视频| 精品网站999www|