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

Android仿微信右上角點(diǎn)擊加號彈出PopupWindow

 更新時(shí)間:2018年04月25日 10:33:04   作者:lisen_then  
這篇文章主要為大家詳細(xì)介紹了Android仿微信右上角點(diǎn)擊加號彈出PopupWindow,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android仿微信右上角點(diǎn)擊加號彈出展示的具體代碼,供大家參考,具體內(nèi)容如下

一、要彈出的布局,隨便設(shè)計(jì)

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  android:background="@drawable/my_phone">


  <TextView
    android:id="@+id/complain_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_marginTop="@dimen/sky_dp_size_10"
    android:layout_marginLeft="10dp"
    android:gravity="center"
    android:text="投訴"
    android:layout_marginRight="10dp"
    android:textColor="@android:color/black"
    android:textSize="18sp" />
  <TextView
    android:id="@+id/expect_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="@dimen/sky_dp_size_10"
    android:gravity="center"
    android:text="屏蔽"
    android:layout_marginRight="10dp"
    android:textColor="@android:color/black"
    android:textSize="18sp" />
</LinearLayout>

二、自定義Popubwindow繼承Popubwindow

public class PopWinShare extends PopupWindow {
  private View mainView;
  private TextView layoutShare, layoutCopy;

  public PopWinShare(Activity paramActivity, View.OnClickListener paramOnClickListener, int paramInt1, int paramInt2) {
    super(paramActivity);
    //窗口布局
    mainView = LayoutInflater.from(paramActivity).inflate(R.layout.popwin_share, null);
    //分享布局
    layoutShare = ((TextView) mainView.findViewById(R.id.complain_tv));
    //復(fù)制布局
    layoutCopy = (TextView) mainView.findViewById(R.id.expect_tv);
    //設(shè)置每個(gè)子布局的事件監(jiān)聽器
    if (paramOnClickListener != null) {
      layoutShare.setOnClickListener(paramOnClickListener);
      layoutCopy.setOnClickListener(paramOnClickListener);
    }
    setContentView(mainView);
    //設(shè)置寬度
    setWidth(paramInt1);
    //設(shè)置高度
    setHeight(paramInt2);
    //設(shè)置顯示隱藏動(dòng)畫
    setAnimationStyle(R.style.AnimTools);
    //設(shè)置背景透明
    setBackgroundDrawable(new ColorDrawable(0));
  }

}

三、彈出動(dòng)畫樣式

<style name="AnimTools" parent="@android:style/Animation">
  <item name="android:windowEnterAnimation">@anim/push_in</item>
  <item name="android:windowExitAnimation">@anim/push_out</item>
</style>

(1)新建anim文件新建push_in和push_out

<scale xmlns:android="http://schemas.android.com/apk/res/android"
  android:fromXScale="1.0"
  android:toXScale="1.0"
  android:fromYScale="0"
  android:toYScale="1.0"
  android:pivotX="0"
  android:pivotY="10%"
  android:duration="200" >

</scale>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
  android:fromXScale="1.0"
  android:toXScale="1.0"
  android:fromYScale="1.0"
  android:toYScale="0"
  android:pivotX="0"
  android:pivotY="10%"
  android:duration="200" >

</scale>

四、使用

 if (popWinShare == null) {
          //自定義的單擊事件
          OnClickLintener paramOnClickListener = new OnClickLintener();
          popWinShare = new PopWinShare(PersonalHomepageActivity.this, paramOnClickListener, 120, 130);
          //監(jiān)聽窗口的焦點(diǎn)事件,點(diǎn)擊窗口外面則取消顯示
          popWinShare.getContentView().setOnFocusChangeListener(new View.OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {
              if (!hasFocus) {
                popWinShare.dismiss();
              }
            }
          });
        }
//設(shè)置默認(rèn)獲取焦點(diǎn)
        popWinShare.setFocusable(true);
//以某個(gè)控件的x和y的偏移量位置開始顯示窗口
        popWinShare.showAsDropDown(tousuTv, 0, 0);
//如果窗口存在,則更新
        popWinShare.update();

(1)按鈕的點(diǎn)擊事件

class OnClickLintener implements View.OnClickListener {

  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.complain_tv:
        Intent intent = new Intent(PersonalHomepageActivity.this, ComplainActivity.class);
        intent.putExtra("about_user_id", friend_id);
        startActivity(intent);
        break;
      case R.id.expect_tv:
        getExpect();
        break;

      default:
        break;
    }

  }

}

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

相關(guān)文章

最新評論

射洪县| 遂平县| 阳信县| 遵义县| 阿尔山市| 调兵山市| 新源县| 阜阳市| 清镇市| 嘉义县| 阳原县| 洮南市| 田阳县| 禄丰县| 汉阴县| 时尚| 沽源县| 屏东市| 巴塘县| 盐池县| 广宗县| 外汇| 右玉县| 永和县| 临江市| 滁州市| 沐川县| 开化县| 武乡县| 高尔夫| 南溪县| 鄂伦春自治旗| 静乐县| 铜梁县| 洛宁县| 如皋市| 象山县| 新竹县| 台江县| 吉林省| 崇阳县|