亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Android仿微信activity滑動關閉效果

發布時間:2020-09-18 00:03:10 來源:腳本之家 閱讀:144 作者:廣州太擁擠 欄目:移動開發

Android仿微信activity滑動關閉功能

1.利用具體利用v4包下的slidingPaneLayout實現透明的activity,代碼如下:

BaseActivity:
public class BaseSlideCloseActivity extends AppCompatActivity implements
  SlidingPaneLayout.PanelSlideListener {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  initSlideBackClose();
  super.onCreate(savedInstanceState);
 }

 private void initSlideBackClose() {
  if (isSupportSwipeBack()) {
   SlidingPaneLayout slidingPaneLayout = new SlidingPaneLayout(this);
   // 通過反射改變mOverhangSize的值為0,
   // 這個mOverhangSize值為菜單到右邊屏幕的最短距離,
   // 默認是32dp,現在給它改成0
   try {
    Field overhangSize = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
    overhangSize.setAccessible(true);
    overhangSize.set(slidingPaneLayout, 0);
   } catch (Exception e) {
    e.printStackTrace();
   }
   slidingPaneLayout.setPanelSlideListener(this);
   slidingPaneLayout.setSliderFadeColor(getResources()
     .getColor(android.R.color.transparent));

   // 左側的透明視圖
   View leftView = new View(this);
   leftView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
   slidingPaneLayout.addView(leftView, 0);

   ViewGroup decorView = (ViewGroup) getWindow().getDecorView();


   // 右側的內容視圖
   ViewGroup decorChild = (ViewGroup) decorView.getChildAt(0);
   decorChild.setBackgroundColor(getResources()
     .getColor(android.R.color.white));
   decorView.removeView(decorChild);
   decorView.addView(slidingPaneLayout);

   // 為 SlidingPaneLayout 添加內容視圖
   slidingPaneLayout.addView(decorChild, 1);
  }
 }

 protected boolean isSupportSwipeBack() {
  return true;
 }

 @Override
 public void onPanelSlide(View panel, float slideOffset) {

 }

 @Override
 public void onPanelOpened(View panel) {
  finish();
 }

 @Override
 public void onPanelClosed(View panel) {

 }
}

activity 透明style:

<resources xmlns:tools="http://schemas.android.com/tools">

 <!-- Base application theme. -->
 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <!-- Customize your theme here. -->
  <item name="colorPrimary">@color/colorPrimary</item>
  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  <item name="colorAccent">@color/colorAccent</item>
 </style>

 <style name="DIY.SlideClose.Transparent.Theme" parent="AppTheme">
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowAnimationStyle">@style/DIY.Animation.SlidingBack</item>
  <item name="android:actionBarStyle">@style/DIYActionBar.Custom</item>
 </style>

 <style name="DIYActionBar.Custom" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
  <item name="displayOptions">showCustom</item>
  <item name="android:background">@android:color/transparent</item>
  <item name="background">@android:color/transparent</item>
  <item name="android:displayOptions" tools:ignore="NewApi">showCustom</item>
  <item name="android:height">?actionBarSize</item>
 </style>

 <style name="DIY.Animation.SlidingBack" parent="@android:style/Animation.Activity">
  <item name="android:activityOpenEnterAnimation">@anim/slide_in_right</item>
  <item name="android:activityOpenExitAnimation">@anim/slide_out_right</item>
  <item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>
  <item name="android:activityCloseExitAnimation">@anim/slide_out_right</item>
  <item name="android:wallpaperOpenEnterAnimation">@anim/slide_in_right</item>
  <item name="android:wallpaperOpenExitAnimation">@anim/slide_out_right</item>
  <item name="android:wallpaperCloseEnterAnimation">@anim/slide_in_right</item>
  <item name="android:wallpaperCloseExitAnimation">@anim/slide_out_right</item>
  <item name="android:wallpaperIntraOpenEnterAnimation">@anim/slide_in_right</item>
  <item name="android:wallpaperIntraOpenExitAnimation">@anim/slide_out_right</item>
  <item name="android:wallpaperIntraCloseEnterAnimation">@anim/slide_in_right</item>
  <item name="android:wallpaperIntraCloseExitAnimation">@anim/slide_out_right</item>
 </style>
 
</resources>

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

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

北宁市| 霸州市| 涿州市| 新河县| 洮南市| 安宁市| 麻城市| 家居| 宝丰县| 石家庄市| 海南省| 交城县| 南川市| 洛扎县| 房产| 无极县| 南昌市| 滁州市| 平武县| 图片| 玛曲县| 保亭| 林西县| 奇台县| 西吉县| 高陵县| 息烽县| 仙游县| 安达市| 哈巴河县| 衡阳县| 上犹县| 阿坝| 沅江市| 太谷县| 尖扎县| 齐齐哈尔市| 彰武县| 防城港市| 尉犁县| 嘉祥县|