1、使用代码设置textview的drawable
// 使用代码设置drawabletop
Drawable drawable = getResources().getDrawable(
R.drawable.driver_home_ic_green);
// / 这一步必须要做,否则不会显示.
drawable.setBounds(0, 0, drawable.getMinimumWidth(),
drawable.getMinimumHeight());
home_tv.setCompoundDrawables(null, drawable, null, null);
home_tv.setTextColor(Color.parseColor("#FF52B68E"));2、PopupWindow的使用
popupWindow = new PopupWindow(contentView,
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setTouchable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
// makeWindowLight();
}
});
// popupWindow.setTouchInterceptor(new OnTouchListener() {
//
// @Override
// public boolean onTouch(View v, MotionEvent event) {
//
// Log.i("mengdd", "onTouch : ");
//
// return false;
// // 这里如果返回true的话,touch事件将被拦截
// // 拦截后 PopupWindow的onTouchEvent不被调用,这样点击外部区域无法dismiss
// }
// });
// // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
// // 我觉得这里是API的一个bug
// popupWindow.setBackgroundDrawable(getResources().getDrawable(
// R.drawable.pop_set));
// 设置好参数之后再show
popupWindow.showAsDropDown(view);3、仿新浪微博添加效果

使用decorView方式(其实自己的布局也是可以的),decorView是framelayout方式。
mAnimateLayout = LayoutInflater.from(this).inflate(R.layout.pop_driver_main, null);
ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
ViewGroup contentView = (ViewGroup) decorView.findViewById(android.R.id.content);
contentView.addView(mAnimateLayout);

472

被折叠的 条评论
为什么被折叠?



