底部弹出的pop

public class MainActivity extends Activity {
    private PopupWindow pop=null;
	private LinearLayout ll_popup;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		init();
		findViewById(R.id.btn).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				ll_popup.startAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.activity_translate_in));
				pop.showAtLocation(MainActivity.this.ll_popup, Gravity.BOTTOM, 0, 0);
				
			}
 
		});
		
	}
	private void init() {
		pop=new PopupWindow(MainActivity.this);
		View view=getLayoutInflater().inflate(R.layout.item_popupwindows, null);
		ll_popup=(LinearLayout)view.findViewById(R.id.ll_popup);
		pop.setWidth(LayoutParams.MATCH_PARENT);
		pop.setHeight(LayoutParams.WRAP_CONTENT);
		pop.setBackgroundDrawable(new BitmapDrawable());
		pop.setFocusable(true);
		pop.setOutsideTouchable(true);
		pop.setContentView(view);
		
		RelativeLayout parent = (RelativeLayout) view.findViewById(R.id.parent);
		Button bt1 = (Button) view
				.findViewById(R.id.item_popupwindows_camera);
		Button bt2 = (Button) view
				.findViewById(R.id.item_popupwindows_Photo);
		Button bt3 = (Button) view
				.findViewById(R.id.item_popupwindows_cancel);
		parent.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				pop.dismiss();
				ll_popup.clearAnimation();
			}
		});
		bt1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				photo();
				pop.dismiss();
				ll_popup.clearAnimation();
			}
		});
		bt2.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				/*Intent intent = new Intent(MainActivity.this,
						AlbumActivity.class);
				startActivity(intent);*/
				overridePendingTransition(R.anim.activity_translate_in, R.anim.activity_translate_out);
				pop.dismiss();
				ll_popup.clearAnimation();
			}
		});
		bt3.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				pop.dismiss();
				ll_popup.clearAnimation();
			}
		});
		
	}
	private static final int TAKE_PICTURE = 0x000001;

	public void photo() {
		Intent openCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
		startActivityForResult(openCameraIntent, TAKE_PICTURE);
	}
	 
}


item_popupwindows的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="<a target=_blank href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>"
    android:id="@+id/parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <LinearLayout
        android:id="@+id/ll_popup"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#ffffff"
        android:orientation="vertical" >
        <TextView
            android:layout_width="match_parent"
            android:layout_height="1dp" />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="55dp"
            android:orientation="horizontal" >
            <Button
                android:id="@+id/item_popupwindows_camera"
                android:layout_width="match_parent"
                android:layout_height="55dp"
                android:background="@drawable/bt_nobgd"
                android:text="拍照"
                android:textColor="#585858"
                android:textSize="18sp" />
        </LinearLayout>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="1px"
            android:layout_marginLeft="80dp"
            android:background="#f2f2f2" />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="55dp"
            android:orientation="horizontal" >
            <Button
                android:id="@+id/item_popupwindows_Photo"
                android:layout_width="match_parent"
                android:layout_height="55dp"
                android:background="@drawable/bt_nobgd"
                android:text="从相册中选取"
                android:textColor="#585858"
                android:textSize="18sp" />
        </LinearLayout>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:background="#f3f3f3" />
        <Button
            android:id="@+id/item_popupwindows_cancel"
            android:layout_width="match_parent"
            android:layout_height="55dp"
            android:background="@drawable/bt_nobgd"
            android:text="取消"
            android:textColor="#585858"
            android:textSize="18sp" />
    </LinearLayout>
</RelativeLayout>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值