Android实现底部缓慢d出菜单

Android实现底部缓慢d出菜单,第1张

概述项目要求要做一个从底部缓慢d出一个ButtonMenu开始编码:MyselfFragmentpackageio.dcloud.H5B79C397.fragment;

项目要求要做一个从底部缓慢d出一个button Menu

开始编码:
MyselfFragment

package io.dcloud.H5B79C397.fragment;import androID.content.Context;import androID.content.Intent;import androID.net.Uri;import androID.os.Bundle;import androID.vIEw.LayoutInflater;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import androID.Widget.button;import androID.Widget.relativeLayout;import androID.Widget.Toast;import com.androID.volley.VolleyError;import com.vanda.vandalibnetwork.fragment.BaseFragment;import java.util.Map;import cn.sharesdk.framework.ShareSDK;import cn.sharesdk.onekeyshare.OnekeyShare;import cn.sharesdk.sina.weibo.SinaWeibo;import cn.sharesdk.tencent.qq.QQ;import cn.sharesdk.wechat.frIEnds.Wechat;import cn.sharesdk.wechat.moments.WechatMoments;import io.dcloud.H5B79C397.R;import io.dcloud.H5B79C397.Urls;import io.dcloud.H5B79C397.activity.BottomMenu;import io.dcloud.H5B79C397.activity.LoginActivity;import io.dcloud.H5B79C397.activity.Myself_About_fae;import io.dcloud.H5B79C397.activity.Myself_Invitation;import io.dcloud.H5B79C397.activity.Myself_help;import io.dcloud.H5B79C397.activity.Myself_setting;import io.dcloud.H5B79C397.activity.Registeractivity;import io.dcloud.H5B79C397.activity.user_management;import io.dcloud.H5B79C397.pojo.InformmationData;import io.dcloud.H5B79C397.util.ActionbarUtil;import io.dcloud.H5B79C397.util.ExtUtils;/** * 用户个人信息界面 */public class MyselfFragment extends BaseFragment<InformmationData> implements VIEw.OnClickListener {  private Context mContext;  private VIEw vIEw;  private BottomMenu menuWindow;  private relativeLayout layout_advise,layout_collect,layout_logo,layout_share,layout_qr_code,layout_help,layout_set,layout_url;  private button btnLogin,btnRegister;  @OverrIDe  public VIEw onCreateVIEw(LayoutInflater inflater,VIEwGroup container,Bundle savedInstanceState) {    vIEw = inflater.inflate(R.layout.fragment_@R_301_4329@ion,container,false);    initVIEw();    return vIEw;  }  @OverrIDe  public voID onStart() {    super.onStart();  }  private voID initVIEw() {    new ActionbarUtil(vIEw,R.ID.actionbar,R.ID.Back,R.ID.Title,R.ID.Activity,"我的管理中心",getActivity(),2);    layout_advise = (relativeLayout) vIEw.findVIEwByID(R.ID.myself_advise);    layout_collect = (relativeLayout) vIEw.findVIEwByID(R.ID.myself_collect);    layout_logo = (relativeLayout) vIEw.findVIEwByID(R.ID.myself_logo);    layout_share = (relativeLayout) vIEw.findVIEwByID(R.ID.myself_share);    layout_qr_code = (relativeLayout) vIEw.findVIEwByID(R.ID.myself_qr_code);    layout_help = (relativeLayout) vIEw.findVIEwByID(R.ID.myself_help);    layout_set = (relativeLayout) vIEw.findVIEwByID(R.ID.myself_set);    layout_url = (relativeLayout) vIEw.findVIEwByID(R.ID.myself_url);    btnLogin = (button) vIEw.findVIEwByID(R.ID.myself_login);    btnRegister = (button) vIEw.findVIEwByID(R.ID.myself_register);    layout_advise.setonClickListener(this);    layout_collect.setonClickListener(this);    layout_logo.setonClickListener(this);    layout_share.setonClickListener(this);    layout_qr_code.setonClickListener(this);    layout_help.setonClickListener(this);    layout_set.setonClickListener(this);    layout_url.setonClickListener(this);    btnLogin.setonClickListener(this);    btnRegister.setonClickListener(this);  }  @OverrIDe  public voID onClick(VIEw v) {    switch (v.getID()) {      case R.ID.myself_advise:        startActivity(new Intent(getActivity(),user_management.class));        break;      case R.ID.myself_collect:        break;      case R.ID.myself_logo:        Intent intent=new Intent(getActivity(),Myself_About_fae.class);        startActivity(intent);        break;      case R.ID.myself_share:        menuWindow = new BottomMenu(mContext,clickListener);        menuWindow.show();        break;      case R.ID.myself_qr_code:        startActivity(new Intent(getActivity(),Myself_Invitation.class));        break;      case R.ID.myself_help:        startActivity(new Intent(getActivity(),Myself_help.class));        break;      case R.ID.myself_set:          startActivity(new Intent(getActivity(),Myself_setting.class));        break;      case R.ID.myself_url:        Uri uri = Uri.parse("http://www.fae.cn/");        Intent intent1 = new Intent(Intent.ACTION_VIEW,uri);        startActivity(intent1);        break;      case R.ID.myself_login:        startActivity(new Intent(getActivity(),LoginActivity.class));        break;      case R.ID.myself_register:        startActivity(new Intent(getActivity(),Registeractivity.class));        break;      default:        break;    }  }  private VIEw.OnClickListener clickListener = new VIEw.OnClickListener(){    public voID onClick(VIEw v) {      switch (v.getID()) {        case R.ID.btn1:          showZIDingYi(Wechat.name);          break;        case R.ID.btn2:          showZIDingYi(WechatMoments.name);          Toast.makeText(mContext,"这是微信朋友圈",Toast.LENGTH_SHORT).show();          break;        case R.ID.sina:          showZIDingYi(SinaWeibo.name);          break;        case R.ID.QQ:          showZIDingYi(QQ.name);          break;        case R.ID.more:          Toast.makeText(mContext,"这是更多",Toast.LENGTH_SHORT).show();          break;        default:          break;      }    }  };  private voID showZIDingYi(String ss){    ShareSDK.initSDK(getActivity());    OnekeyShare oks = new OnekeyShare();    oks.setSilent(false);    oks.setDialogMode();    oks.setText("xxxxxxxxx");    //oks.setimageUrl("http://sharesdk.cn");    oks.setPlatform(ss);    oks.show(getActivity());  }  public static MyselfFragment newInstance(Context context) {    MyselfFragment fragment = new MyselfFragment();    fragment.mContext = context;    return fragment;  }  public MyselfFragment() {    // required empty public constructor  }  @OverrIDe  protected voID processData(InformmationData response) {    super.processData(response);    if (response != null) {    }  }  @OverrIDe  protected voID errorData(VolleyError volleyError) {    super.errorData(volleyError);    ExtUtils.errorLog("-----MyselfFragment----volleyError--------->",volleyError + "");  }  @OverrIDe  protected String getRequestUrl() {    return Urls.URL_PREFIX + "";  }  @OverrIDe  protected Class<InformmationData> getResponseDataClass() {    return InformmationData.class;  }  @OverrIDe  protected Map<String,String> getParamMap() {    return null;  }}

BottomMenu

package io.dcloud.H5B79C397.activity;import androID.app.Actionbar;import androID.app.Activity;import androID.content.Context;import androID.graphics.drawable.colorDrawable;import androID.vIEw.Gravity;import androID.vIEw.LayoutInflater;import androID.vIEw.MotionEvent;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import androID.Widget.button;import androID.Widget.PopupWindow;import io.dcloud.H5B79C397.R;import static io.dcloud.H5B79C397.R.ID.btn1;import static io.dcloud.H5B79C397.R.ID.btn2;/** * Created by administrator on 2017/7/21 0021. */public class BottomMenu implements VIEw.OnClickListener,VIEw.OntouchListener {  private PopupWindow popupWindow;  private button wechat,frIEnd,qq,sina,more,btnCancel;  private VIEw mMenuVIEw;  private Activity mContext;  private VIEw.OnClickListener clickListener;  public BottomMenu(Context context,VIEw.OnClickListener clickListener) {    LayoutInflater inflater = LayoutInflater.from(context);    this.clickListener=clickListener;    mContext= (Activity) context;    mMenuVIEw = inflater.inflate(R.layout.layout_popwindow,null);    wechat= (button) mMenuVIEw.findVIEwByID(btn1);    frIEnd= (button) mMenuVIEw.findVIEwByID(btn2);    qq=(button)mMenuVIEw.findVIEwByID(R.ID.QQ) ;    sina=(button)mMenuVIEw.findVIEwByID(R.ID.sina);    more=(button)mMenuVIEw.findVIEwByID(R.ID.more);    btnCancel = (button) mMenuVIEw.findVIEwByID(R.ID.btn_cancel);    btnCancel.setonClickListener(this);    wechat.setonClickListener(this);    frIEnd.setonClickListener(this);    qq.setonClickListener(this);    sina.setonClickListener(this);    more.setonClickListener(this);    popupWindow=new PopupWindow(mMenuVIEw,Actionbar.LayoutParams.MATCH_PARENT,Actionbar.LayoutParams.WRAP_CONTENT,true);    popupWindow.setAnimationStyle(R.style.popwin_anim_style);    colorDrawable DW = new colorDrawable(context.getResources().getcolor(R.color.apha));    popupWindow.setBackgroundDrawable(DW);    mMenuVIEw.setontouchListener(this);  }  /**   * 显示菜单   */  public voID show(){    //得到当前activity的rootVIEw    VIEw rootVIEw=((VIEwGroup)mContext.findVIEwByID(androID.R.ID.content)).getChildAt(0);    popupWindow.showAtLocation(rootVIEw,Gravity.BottOM|Gravity.CENTER_HORIZONTAL,0);  }  @OverrIDe  public voID onClick(VIEw vIEw) {    popupWindow.dismiss();    switch (vIEw.getID()) {      case R.ID.btn_cancel:        break;      default:        clickListener.onClick(vIEw);        break;    }  }  @OverrIDe  public boolean ontouch(VIEw arg0,MotionEvent event) {    int height = mMenuVIEw.findVIEwByID(R.ID.pop_layout).gettop();    int y=(int) event.getY();    if(event.getAction()==MotionEvent.ACTION_UP){      if(y<height){        popupWindow. dismiss();      }    }    return true;  }}

layout_popwindow.xml

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"  androID:layout_wIDth="fill_parent"  androID:layout_height="wrap_content"  androID:gravity="center_horizontal"  androID:orIEntation="vertical" >  <linearLayout    androID:ID="@+ID/pop_layout"    androID:layout_wIDth="fill_parent"    androID:layout_height="wrap_content"    androID:layout_alignParentBottom="true"    androID:gravity="center_horizontal"    androID:layout_marginleft="20dp"    androID:layout_marginRight="20dp"    androID:orIEntation="vertical" >    <button      androID:background="#F2F2F2"      androID:ID="@+ID/btn1"      androID:layout_wIDth="match_parent"      androID:layout_height="40dp"      androID:text="分享到微信好友"      androID:textcolor="@color/black"       />    <button      androID:ID="@+ID/btn2"      androID:layout_wIDth="match_parent"      androID:layout_height="40dp"      androID:text="分享到微信朋友圈"      androID:layout_margintop="5dp"      androID:textcolor="@color/black"      androID:background="#F2F2F2"      />    <button      androID:ID="@+ID/QQ"      androID:layout_wIDth="match_parent"      androID:layout_height="40dp"      androID:text="分享到QQ"      androID:layout_margintop="5dp"      androID:textcolor="@color/black"      androID:background="#F2F2F2"      />    <button      androID:ID="@+ID/sina"      androID:layout_wIDth="match_parent"      androID:layout_height="40dp"      androID:text="分享到新浪微博"      androID:layout_margintop="5dp"      androID:textcolor="@color/black"      androID:background="#F2F2F2"      />    <button      androID:ID="@+ID/more"      androID:layout_wIDth="match_parent"      androID:layout_height="40dp"      androID:text="分享到更多..."      androID:layout_margintop="5dp"      androID:textcolor="@color/black"      androID:background="#F2F2F2"      />    <button      androID:ID="@+ID/btn_cancel"      androID:layout_wIDth="match_parent"      androID:layout_height="50dp"      androID:text="取消"      androID:layout_marginBottom="10dp"      androID:layout_margintop="15dp"      androID:background="#F2F2F2"      androID:Alpha="100"      androID:textStyle="bold" />  </linearLayout></relativeLayout>

包anim//放在res目录下其中包括ppwindow_hIDe_anim.xml和ppwindow_show_anim.xml
其中ppwindow_hIDe_anim.xml

<?xml version="1.0" enCoding="utf-8"?><set xmlns:androID="http://schemas.androID.com/apk/res/androID">  <translate    androID:duration="300"    androID:fromXDelta="0"    androID:toXDelta="0"    androID:fromYDelta="0"    androID:toYDelta="1920"    />  <Alpha    androID:duration="300"    androID:fromAlpha="1"    androID:toAlpha="0"    /></set>

其中ppwindow_show_anim.xml

<?xml version="1.0" enCoding="utf-8"?><set xmlns:androID="http://schemas.androID.com/apk/res/androID">  <translate    androID:duration="300"    androID:fromXDelta="0"    androID:toXDelta="0"    androID:fromYDelta="1920"    androID:toYDelta="0"    />  <Alpha    androID:duration="300"    androID:fromAlpha="0"    androID:toAlpha="1"    /></set>

最后上图:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。

总结

以上是内存溢出为你收集整理的Android实现底部缓慢d出菜单全部内容,希望文章能够帮你解决Android实现底部缓慢d出菜单所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1144203.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存