Android LinearLayout整个布局设置不可点击
1,activity的xml布局(布局中有个Button按钮,点击按钮弹出一个popupwindow )
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:background="@drawable/ic_launcher_background"
    tools:context=".MainActivity">
<Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:onClick="click"
        android:textSize="30sp"
        android:text="弹窗Popupwindow"/>
</LinearLayout>
2,上图中有白色背景的popupwindow 的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:gravity="center"
    android:id="@+id/ll_popup">
<LinearLayout
        android:id="@+id/ll_popup_content"
        android:layout_width="600dp"
        android:layout_height="400dp"
        android:gravity="center"
        android:background="@android:color/white">
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="250dp"
            android:padding="10dp"
            android:src="@drawable/fengjing"
            android:layout_marginRight="20dp"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="250dp"
            android:padding="10dp"
            android:src="@drawable/small"/>
    </LinearLayout>
</LinearLayout>
3,MainActivity的代码实现:
public class MainActivity extends AppCompatActivity {
    private View pop;
private LinearLayout ll_popup,ll_popup_content;
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
pop = View.inflate(this, R.layout.popupwindow_test, null);
        ll_popup = pop.findViewById(R.id.ll_popup);
        ll_popup_content = pop.findViewById(R.id.ll_popup_content);
        ll_popup_content.setOnClickListener(null);//Linearloyout就不可点击了
    }
public void click(View view) {
       final PopupWindow popupWindow = new PopupWindow(pop, MATCH_PARENT, MATCH_PARENT);
        ll_popup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popupWindow.dismiss();
            }
        });
        popupWindow.showAtLocation(getWindow().getDecorView(), Gravity.TOP,0,0);
    }
@Override
    public void onWindowFocusChanged(boolean hasFocus) {
        //完全沉浸式
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus && Build.VERSION.SDK_INT >= 19) {
            View decorView = getWindow().getDecorView(http://www.my516.com);
            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }
}
---------------------
Android LinearLayout整个布局设置不可点击的更多相关文章
- Android LinearLayout线性布局详解
		
为了更好地管理Android应用的用户界面里的各组件,Android提供了布局管理器.通过使用布局管理器,Android应用图形用户界面具有良好的平台无关性.推荐使用布局管理器来管理组件的分布.大小, ...
 - Android linearlayout常用布局
		
用linearlayout完成这样的布局效果,这样的布局还是比较常用的,具体的xml代码如下: <LinearLayout xmlns:android="http://schemas. ...
 - Android LinearLayout线性布局
		
LinearLayout是线性布局控件:要么横向排布,要么竖向排布 决定性属性:必须有的! android:orientation:vertical (垂直方向) .horizontal(水平方向) ...
 - Android 手机卫士--实现设置界面的一个条目布局结构
		
本文地址:http://www.cnblogs.com/wuyudong/p/5908986.html,转载请注明源地址. 本文以及后续文章,将一步步完善功能列表: 要点击九宫格中的条目,需要注册点击 ...
 - 无废话Android之常见adb指令、电话拨号器、点击事件的4种写法、短信发送器、Android 中各种布局(1)
		
1.Android是什么 手机设备的软件栈,包括一个完整的操作系统.中间件.关键的应用程序,底层是linux内核,安全管理.内存管理.进程管理.电源管理.硬件驱动 2.Dalvik VM 和 JVM ...
 - 关于android LinearLayout的比例布局(转载)
		
关于android LinearLayout的比例布局,主要有以下三个属性需要设置: 1,android:layout_width,android:layout_height,android:layo ...
 - 个人经验 - Android的RelativeLayout布局的layout_height属性设置为wrap_content时的坑
		
Android的RelativeLayout布局的layout_height属性设置为wrap_content时的坑: 此坑出现的条件: 1.RelativeLayout布局的layout_heigh ...
 - android LinearLayout和RelativeLayout实现精确布局
		
先明确几个概念的区别: padding margin:都是边距的含义,关键问题得明白是什么相对什么的边距padding:是控件的内容相对控件的边缘的边距. margin :是控件边缘相对父空间的边距 ...
 - Android布局管理详解(1)—— LinearLayout 线性布局
		
Android的布局方式共有6种,分别是LinearLayout(线性布局).TableLayout(表格布局).FrameLayout(帧布局).RelativeLayout(相对布局).GridL ...
 
随机推荐
- Spring MVC-视图解析器(View Resolverr)-内部资源视图解析器(Internal Resource View Resolver)示例(转载实践)
			
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_internalresourceviewresolver.htm 说明:示例基于S ...
 - AngularJS:添加检查密码输入是否一致的功能
			
感谢作者(http://blog.brunoscopelliti.com/angularjs-directive-to-check-that-passwords-match) 利用AngularJS的 ...
 - 将XML文件转化成NSData对象
			
NSData *xmlData = [[NSData alloc]initWithContentsOfFile:[NSString stringWithFormat:@"%@/People. ...
 - DotNetBar.Bar作为容器使用的方法及Text更新原理
			
DotNetBar.Bar作为容器使用的方法及Text更新原理 老帅 一.容器用法 控件DevComponents.DotNetBar.Ba ...
 - C语言之基本算法40—字符串删除元音字母倒序输出
			
//字符串,数组 /* ================================================================== 题目: 输入一行字符,将辅音字母按反序输出 ...
 - 蒟蒻的trie树专题
			
POJ 3630 Phone List: 模板 ///meek #include<bits/stdc++.h> using namespace std; using namespace s ...
 - 1366 xth 的第 12 枚硬币
			
1366 xth 的第 12 枚硬币 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Description 传说 xth 曾 ...
 - linux(centos)下安装git并上传代码些许步骤(亲自验证过的步骤)
			
曾经听说了好多次github,但直到近期才第一次学习使用github来托管自己在linux下的代码! 说实话.我自己在使用的时候从网上查了好多教程.但总认为难以掌握(步骤过于繁琐),自己操作的时候还 ...
 - bzoj 1050 [ HAOI 2006 ] 旅行comf —— 并查集
			
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1050 没思路的话想想暴力就好了... 首先,比值最小就是确定最小值后最大值最小: 怎样确定最 ...
 - Java数据库编程及Java XML解析技术
			
1.JDBC概述 A. 什么是JDBC? Java DataBase Connectivity:是一种用于执行SQL语句的Java API,它由一组用Java语言编写的类和接口组成.通过这些类和接口 ...