底部弹出popwindow挡住手机系统键

移动开发 码拜 8年前 (2015-11-28) 1160次浏览
小弟是搞安卓的,最近有一个收藏功能,在底部弹出popwindow。有的型号手机就会把系统键挡住(下图),那个高手有好的解决方法。
先上码:
//这是创建的popwindow
View view = LayoutInflater.from(ProductDetailActivity.this).inflate(R.layout.prod_collect_layout,null);
// 创建PopupWindow实例,200,LayoutParams.MATCH_PARENT分别是宽度和高度
popupWindow = new PopupWindow(view, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, true);
popupWindow.showAtLocation(v, Gravity.BOTTOM, 0, 0);
// 点击其他地方消失
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss();
popupWindow = null;
}
return false;
}
});
//这是popwindow的layout
<?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:orientation=”vertical”>
<LinearLayout
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:background=”@android:color/white”
android:orientation=”vertical”>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:layout_marginTop=”10dp”
android:gravity=”center”
android:padding=”10dp”
android:text=”收藏到” />
<LinearLayout
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”>
<LinearLayout
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:gravity=”center”
android:padding=”10dp”>
<CheckBox
android:id=”@+id/my_favorite”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” />
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”本人的收藏”
android:textSize=”18sp” />
</LinearLayout>
<LinearLayout
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:gravity=”center”
android:padding=”10dp”>
<CheckBox
android:id=”@+id/my_product”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” />
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”本人的宝贝”
android:textSize=”18sp” />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width=”fill_parent”
android:layout_height=”1dp”
android:background=”#80bebebe”></ImageView>
<LinearLayout
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:layout_marginTop=”20dp”>
<Button
android:id=”@+id/cancle”
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:background=”@android:color/transparent”
android:gravity=”center”
android:padding=”10dp”
android:text=”取消”
android:textSize=”18sp” />
<Button
android:id=”@+id/collect”
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:background=”@android:color/transparent”
android:gravity=”center”
android:padding=”10dp”
android:text=”收藏”
android:textSize=”18sp” />
</LinearLayout>
</LinearLayout>
</LinearLayout>
//下是效果图底部弹出popwindow挡住手机系统键底部弹出popwindow挡住手机系统键
解决方案:20分
你从你底部的购物车view那里弹出
解决方案:20分
XML 布局  加上 paddingBottom 试试

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明底部弹出popwindow挡住手机系统键
喜欢 (0)
[1034331897@qq.com]
分享 (0)