package com.loaderman.customviewdemo;
import android.content.Context;
import android.view.View;
import android.widget.PopupWindow;
public class CommonPopupWindow extends PopupWindow {
final PopupController controller;
@Override
public int getWidth() {
return controller.mPopupView.getMeasuredWidth();
}
@Override
public int getHeight() {
return controller.mPopupView.getMeasuredHeight();
}
public interface ViewInterface {
void getChildView(View view, int layoutResId);
}
private CommonPopupWindow(Context context) {
controller = new PopupController(context, this);
}
@Override
public void dismiss() {
super.dismiss();
controller.setBackGroundLevel(1.0f);
}
public static class Builder {
private final PopupController.PopupParams params;
private ViewInterface listener;
public Builder(Context context) {
params = new PopupController.PopupParams(context);
}
/**
* @param layoutResId 设置PopupWindow 布局ID
* @return Builder
*/
public Builder setView(int layoutResId) {
params.mView = null;
params.layoutResId = layoutResId;
return this;
}
/**
* @param view 设置PopupWindow布局
* @return Builder
*/
public Builder setView(View view) {
params.mView = view;
params.layoutResId = 0;
return this;
}
/**
* 设置子View
*
* @param listener ViewInterface
* @return Builder
*/
public Builder setViewOnclickListener(ViewInterface listener) {
this.listener = listener;
return this;
}
/**
* 设置宽度和高度 如果不设置 默认是wrap_content
*
* @param width 宽
* @return Builder
*/
public Builder setWidthAndHeight(int width, int height) {
params.mWidth = width;
params.mHeight = height;
return this;
}
/**
* 设置背景灰色程度
*
* @param level 0.0f-1.0f
* @return Builder
*/
public Builder setBackGroundLevel(float level) {
params.isShowBg = true;
params.bg_level = level;
return this;
}
/**
* 是否可点击Outside消失
*
* @param touchable 是否可点击
* @return Builder
*/
public Builder setOutsideTouchable(boolean touchable) {
params.isTouchable = touchable;
return this;
}
/**
* 设置动画
*
* @return Builder
*/
public Builder setAnimationStyle(int animationStyle) {
params.isShowAnim = true;
params.animationStyle = animationStyle;
return this;
}
public CommonPopupWindow create() {
final CommonPopupWindow popupWindow = new CommonPopupWindow(params.mContext);
params.apply(popupWindow.controller);
if (listener != null && params.layoutResId != 0) {
listener.getChildView(popupWindow.controller.mPopupView, params.layoutResId);
}
CommonUtil.measureWidthAndHeight(popupWindow.controller.mPopupView);
return popupWindow;
}
}
}
package com.loaderman.customviewdemo;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.PopupWindow;
class PopupController {
private int layoutResId;//布局id
private Context context;
private PopupWindow popupWindow;
View mPopupView;//弹窗布局View
private View mView;
private Window mWindow;
PopupController(Context context, PopupWindow popupWindow) {
this.context = context;
this.popupWindow = popupWindow;
}
public void setView(int layoutResId) {
mView = null;
this.layoutResId = layoutResId;
installContent();
}
public void setView(View view) {
mView = view;
this.layoutResId = 0;
installContent();
}
private void installContent() {
if (layoutResId != 0) {
mPopupView = LayoutInflater.from(context).inflate(layoutResId, null);
} else if (mView != null) {
mPopupView = mView;
}
popupWindow.setContentView(mPopupView);
}
/**
* 设置宽度
*
* @param width 宽
* @param height 高
*/
private void setWidthAndHeight(int width, int height) {
if (width == 0 || height == 0) {
//如果没设置宽高,默认是WRAP_CONTENT
popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
} else {
popupWindow.setWidth(width);
popupWindow.setHeight(height);
}
}
/**
* 设置背景灰色程度
*
* @param level 0.0f-1.0f
*/
void setBackGroundLevel(float level) {
mWindow = ((Activity) context).getWindow();
WindowManager.LayoutParams params = mWindow.getAttributes();
params.alpha = level;
mWindow.setAttributes(params);
}
/**
* 设置动画
*/
private void setAnimationStyle(int animationStyle) {
popupWindow.setAnimationStyle(animationStyle);
}
/**
* 设置Outside是否可点击
*
* @param touchable 是否可点击
*/
private void setOutsideTouchable(boolean touchable) {
popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));//设置透明背景
popupWindow.setOutsideTouchable(touchable);//设置outside可点击
popupWindow.setFocusable(touchable);
}
static class PopupParams {
public int layoutResId;//布局id
public Context mContext;
public int mWidth, mHeight;//弹窗的宽和高
public boolean isShowBg, isShowAnim;
public float bg_level;//屏幕背景灰色程度
public int animationStyle;//动画Id
public View mView;
public boolean isTouchable = true;
public PopupParams(Context mContext) {
this.mContext = mContext;
}
public void apply(PopupController controller) {
if (mView != null) {
controller.setView(mView);
} else if (layoutResId != 0) {
controller.setView(layoutResId);
} else {
throw new IllegalArgumentException("PopupView's contentView is null");
}
controller.setWidthAndHeight(mWidth, mHeight);
controller.setOutsideTouchable(isTouchable);//设置outside可点击
if (isShowBg) {
//设置背景
controller.setBackGroundLevel(bg_level);
}
if (isShowAnim) {
controller.setAnimationStyle(animationStyle);
}
}
}
}
package com.loaderman.customviewdemo;
import android.view.View;
public class CommonUtil {
/**
* 测量View的宽高
*
* @param view View
*/
public static void measureWidthAndHeight(View view) {
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
view.measure(w, h);
}
}
package com.loaderman.customviewdemo;
import android.content.Context;
public class DpUtil {
/**
* dp转换成px
*
* @param context Context
* @param dp dp
* @return px值
*/
public static float dp2px(Context context, float dp) {
final float scale = context.getResources().getDisplayMetrics().density;
return dp * scale + 0.5f;
}
}
package com.loaderman.customviewdemo;
import android.view.View;
public interface MyOnclickListener {
void onItemClick(View view, int position);
}
package com.loaderman.customviewdemo;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
public class PopupAdapter extends RecyclerView.Adapter<PopupAdapter.MyViewHolder> {
private Context mContext;
private List<String> list;
private MyOnclickListener myItemClickListener;
public PopupAdapter(Context mContext) {
this.mContext = mContext;
}
public void setOnItemClickListener(MyOnclickListener listener) {
this.myItemClickListener = listener;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.popup_item, parent, false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
holder.choice_text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (myItemClickListener != null) {
myItemClickListener.onItemClick(v, position);
}
}
});
}
@Override
public int getItemCount() {
return 15;
}
public class MyViewHolder extends RecyclerView.ViewHolder {
TextView choice_text;
public MyViewHolder(final View itemView) {
super(itemView);
choice_text = (TextView) itemView.findViewById(R.id.choice_text);
}
}
}
package com.loaderman.customviewdemo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
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.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements CommonPopupWindow.ViewInterface {
private CommonPopupWindow popupWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
//向下弹出
public void showDownPop(View view) {
if (popupWindow != null && popupWindow.isShowing()) return;
popupWindow = new CommonPopupWindow.Builder(this)
.setView(R.layout.popup_down)
.setWidthAndHeight(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
.setAnimationStyle(R.style.AnimDown)
.setViewOnclickListener(this)
.setOutsideTouchable(true)
.create();
popupWindow.showAsDropDown(view);
//得到button的左上角坐标
// int[] positions = new int[2];
// view.getLocationOnScreen(positions);
// popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.NO_GRAVITY, 0, positions[1] + view.getHeight());
}
//向右弹出
public void showRightPop(View view) {
if (popupWindow != null && popupWindow.isShowing()) return;
popupWindow = new CommonPopupWindow.Builder(this)
.setView(R.layout.popup_left_or_right)
.setWidthAndHeight(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
.setAnimationStyle(R.style.AnimHorizontal)
.setViewOnclickListener(this)
.create();
popupWindow.showAsDropDown(view, view.getWidth(), -view.getHeight());
//得到button的左上角坐标
// int[] positions = new int[2];
// view.getLocationOnScreen(positions);
// popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.NO_GRAVITY, positions[0] + view.getWidth(), positions[1]);
}
//向左弹出
public void showLeftPop(View view) {
if (popupWindow != null && popupWindow.isShowing()) return;
popupWindow = new CommonPopupWindow.Builder(this)
.setView(R.layout.popup_left_or_right)
.setWidthAndHeight(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
.setAnimationStyle(R.style.AnimRight)
.setViewOnclickListener(this)
.create();
popupWindow.showAsDropDown(view, -popupWindow.getWidth(), -view.getHeight());
//得到button的左上角坐标
// int[] positions = new int[2];
// view.getLocationOnScreen(positions);
// popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.NO_GRAVITY, positions[0] - popupWindow.getWidth(), positions[1]);
}
//全屏弹出
public void showAll(View view) {
if (popupWindow != null && popupWindow.isShowing()) return;
View upView = LayoutInflater.from(this).inflate(R.layout.popup_up, null);
//测量View的宽高
CommonUtil.measureWidthAndHeight(upView);
popupWindow = new CommonPopupWindow.Builder(this)
.setView(R.layout.popup_up)
.setWidthAndHeight(ViewGroup.LayoutParams.MATCH_PARENT, upView.getMeasuredHeight())
.setBackGroundLevel(0.5f)//取值范围0.0f-1.0f 值越小越暗
.setAnimationStyle(R.style.AnimUp)
.setViewOnclickListener(this)
.create();
popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
}
//向上弹出
public void showUpPop(View view) {
if (popupWindow != null && popupWindow.isShowing()) return;
popupWindow = new CommonPopupWindow.Builder(this)
.setView(R.layout.popup_left_or_right)
.setWidthAndHeight(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
.setViewOnclickListener(this)
.create();
popupWindow.showAsDropDown(view, 0, -(popupWindow.getHeight() + view.getMeasuredHeight()));
//得到button的左上角坐标
// int[] positions = new int[2];
// view.getLocationOnScreen(positions);
// popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.NO_GRAVITY, positions[0], positions[1] - popupWindow.getHeight());
}
public void showReminder(View view) {
if (popupWindow != null && popupWindow.isShowing()) return;
popupWindow = new CommonPopupWindow.Builder(this)
.setView(R.layout.query_info)
.setWidthAndHeight(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
.create();
popupWindow.showAsDropDown(view, (int) (-popupWindow.getWidth() + DpUtil.dp2px(this, 20)), -(popupWindow.getHeight() + view.getMeasuredHeight()));
}
@Override
public void getChildView(View view, int layoutResId) {
//获得PopupWindow布局里的View
switch (layoutResId) {
case R.layout.popup_down:
RecyclerView recycle_view = (RecyclerView) view.findViewById(R.id.recycle_view);
recycle_view.setLayoutManager(new GridLayoutManager(this, 3));
PopupAdapter mAdapter = new PopupAdapter(this);
recycle_view.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(new MyOnclickListener() {
@Override
public void onItemClick(View view, int position) {
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
break;
case R.layout.popup_up:
Button btn_take_photo = (Button) view.findViewById(R.id.btn_take_photo);
Button btn_select_photo = (Button) view.findViewById(R.id.btn_select_photo);
Button btn_cancel = (Button) view.findViewById(R.id.btn_cancel);
btn_take_photo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "拍照", Toast.LENGTH_SHORT).show();
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
btn_select_photo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "相册选取", Toast.LENGTH_SHORT).show();
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
btn_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (popupWindow != null) {
popupWindow.dismiss();
}
return true;
}
});
break;
case R.layout.popup_left_or_right:
TextView tv_like = (TextView) view.findViewById(R.id.tv_like);
TextView tv_hate = (TextView) view.findViewById(R.id.tv_hate);
tv_like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "赞一个", Toast.LENGTH_SHORT).show();
popupWindow.dismiss();
}
});
tv_hate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "踩一下", Toast.LENGTH_SHORT).show();
popupWindow.dismiss();
}
});
break;
}
}
}
anim文件下创建
push_bottom_in.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- 上下滑入式 -->
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="200"
android:fromYDelta="50%p"
android:toYDelta="0"/>
</set>
push_bottom_out.xml
<?xml version="1.0" encoding="utf-8"?><!-- 上下滑入式 -->
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="200"
android:fromYDelta="0"
android:toYDelta="50%p" />
</set>
push_scale_in.xml
<?xml version="1.0" encoding="utf-8"?><!-- 左上角扩大-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="true">
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
push_scale_out.xml
<?xml version="1.0" encoding="utf-8"?><!-- 左上角扩大-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="true">
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXScale="1.0"
android:toYScale="0.001" />
</set>
push_scale__left_in.xml
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromXScale="0.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXScale="1.0"
android:toYScale="1.0" />
push_scale__left_out.xml
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXScale="0.0"
android:toYScale="1.0" />
push_scale__right_in.xml
<?xml version="1.0" encoding="utf-8"?><!-- 左上角扩大-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="true">
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromXScale="0.0"
android:fromYScale="1.0"
android:pivotX="100%"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
push_scale__right_out.xml
<?xml version="1.0" encoding="utf-8"?><!-- 左上角扩大-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="true">
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="100%"
android:toXScale="0.0"
android:toYScale="1.0" />
</set>
color文件下创建
popup_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#6fb30d" android:state_pressed="true" />
<item android:color="#FF000000" />
</selector>
drawable文件下
popup_grey_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="6dp" />
<solid android:color="@color/black_deep" />
</shape>
popup_item_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="6dp" />
<padding android:bottom="10dp" android:left="20dp" android:right="20dp" android:top="10dp" />
<solid android:color="@color/white" />
<stroke android:width="1dp" android:color="@color/green_deep_color" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="6dp" />
<solid android:color="@color/white" />
<padding android:bottom="10dp" android:left="20dp" android:right="20dp" android:top="10dp" />
<stroke android:width="1dp" android:color="@color/black_deep" />
</shape>
</item>
</selector>
layout文件下创建
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:onClick="showDownPop"
android:text="向下弹出"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="150dp"
android:onClick="showRightPop"
android:text="向右弹出"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="200dp"
android:onClick="showLeftPop"
android:text="向左弹出"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:onClick="showAll"
android:text="全屏弹出(带阴影)"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:onClick="showUpPop"
android:text="向上弹出"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="40dp"
android:layout_marginRight="40dp"
android:onClick="showReminder"
android:src="@mipmap/query_icon_normal"/>
</RelativeLayout>
popup_down.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#b0000000"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycle_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:overScrollMode="never" />
</LinearLayout>
popup_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/choice_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/popup_item_bg"
android:text="王者XXOO"
android:textColor="@color/popup_color" />
</RelativeLayout>
popup_left_or_right.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="161dp"
android:layout_height="40dp"
android:background="@drawable/popup_grey_bg"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_like"
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="赞一个"
android:textColor="@color/white"
android:textSize="16dp" />
<View
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:background="@color/bbbbbb_2.3" />
<TextView
android:id="@+id/tv_hate"
android:layout_width="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="踩一下"
android:textColor="@color/white"
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>
popup_up.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pop_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:orientation="vertical">
<Button
android:id="@+id/btn_take_photo"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="拍照"
android:textColor="#282828"
android:textSize="16sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/gray_holo_light" />
<Button
android:id="@+id/btn_select_photo"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="相册选取"
android:textColor="#282828"
android:textSize="16sp" />
<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="@color/gray_holo_light" />
<Button
android:id="@+id/btn_cancel"
style="?android:attr/borderlessButtonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="取消"
android:textColor="#282828"
android:textSize="16sp" />
</LinearLayout>
</RelativeLayout>
query_info.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical">
<TextView
android:layout_width="250dp"
android:layout_height="wrap_content"
android:background="@drawable/mark_pic_normal"
android:gravity="center_vertical"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="20dp"
android:text="你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好你好好你好好好" />
</LinearLayout>
color.xml
<color name="holo_blue_light">#ff33b5e5</color>
<color name="white">#ffffff</color>
<color name="black_deep">#FF000000</color>
<color name="bbbbbb_2.3">#bbbbbb</color>
<color name="green_deep_color">#6fb30d</color>
<item name="gray_holo_light" type="color">#ffd0d0d0</item>
styles.xml
<style name="AnimDown" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@anim/push_scale_in</item>
<item name="android:windowExitAnimation">@anim/push_scale_out</item>
</style>
<style name="AnimUp" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@anim/push_bottom_in</item>
<item name="android:windowExitAnimation">@anim/push_bottom_out</item>
</style>
<style name="AnimHorizontal" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@anim/push_scale_left_in</item>
<item name="android:windowExitAnimation">@anim/push_scale_left_out</item>
</style>
<style name="AnimRight" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@anim/push_scale_right_in</item>
<item name="android:windowExitAnimation">@anim/push_scale_right_out</item>
</style>
效果图: