android 获得屏幕宽度和高度
<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"
android:orientation="vertical" > <!-- 显示网络状态的标签控件 -->
<TextView
android:id="@+id/myyl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp" /> </RelativeLayout>
package com.example.yanlei.yl; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView; public class MainActivity extends AppCompatActivity { private TextView pTextView; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WindowManager wm = this.getWindowManager();
int width = wm.getDefaultDisplay().getWidth(); int height = wm.getDefaultDisplay().getHeight();
pTextView=(TextView)findViewById(R.id.myyl);
pTextView.setText("屏幕宽度:"+width+",屏幕高度:"+height); } }
android 获得屏幕宽度和高度的更多相关文章
- 获取Android 手机屏幕宽度和高度以及获取Android手机序列号
1.获取Android 手机屏幕宽度 1 DisplayMetrics dm = new DisplayMetrics(); 2 this.getWindowManager().getDefaultD ...
- js获取手机屏幕宽度、高度
网页可见区域宽:document.body.clientWidth 网页可见区域高:document.body.clientHeight 网页可见区域宽:document.body.offsetWid ...
- JS 和 Jq 获取客户端各种屏幕宽度和高度
//javascript 网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeight 网页可见区域宽: documen ...
- Android 获得屏幕的宽高度
在View构造函数中获得屏幕的宽高 public class GameView extends View { public GameView(Context context) { Display d ...
- css表示屏幕宽度和高度
expression(document.body.offsetWidth + "px"); expression(document.body.offsetHeight + &quo ...
- iOS 根据屏幕宽度, 高度判断手机设备
#define iPhone_5 [UIScreen mainScreen].bounds.size.width == 320.0 #define iPhone_6 [UIScreen mainScr ...
- android获得屏幕高度和宽度
获取屏幕的宽度与高度有以下几种方法: .WindowManager wm = (WindowManager) getContext() .getSystemSe ...
- Android取得屏幕的高度和宽度
//获得手机屏幕的宽度和高度 width=getWindowManager().getDefaultDisplay().getWidth(); height=getWindowManager().ge ...
- android之获取屏幕的宽度和高度
获取屏幕的宽度和高度: 方法一: //获取屏幕的宽度 public static int getScreenWidth(Context context) { WindowManager manager ...
随机推荐
- <MySQL>入门一 查询 DQL
1. 数据库表 1.1 员工表 Create Table CREATE TABLE `employees` ( `employee_id` ) NOT NULL AUTO_INCREMENT, `fi ...
- MySQL开启日志跟踪
在开发过程中有时候会遇到sql相关的问题,但是有时候代码中不会直接看到真实的sql,想要看到mysql中实际执行的是什么sql,可以通过开启日志跟踪方式查看. 1 开启日志跟踪 SET GLOBAL ...
- Pycharm快捷键及Python常用转义符
不管是windows.xshell或者pycharm,学会使用快捷键都会使学习工作达到事半功倍的效果.这篇博客收集了部分常用的pycharm快捷键,分享给大家,希望对大家有用. 1. 常用快捷键 Py ...
- python 中requests 模块用py2exe生成exe后SSL certificate exception的问题
[('system library', 'fopen', 'No such process'), ('BIO routines', 'BIO_new_file', 'no such file'), ( ...
- clipboard 在 vue 中的使用
简介 页面中用 clipboard 可以进行复制粘贴,clipboard能将内容直接写入剪切板 安装 npm install --save clipboard 使用方法一 <template&g ...
- shell-code-exerciese-1
&&&&&&&&&&&&&&&&&&&& ...
- ZZULIoj 1907 小火山的宝藏收益
Description 进去宝藏后, 小火山发现宝藏有N个房间,且这n个房间通过N-1道门联通. 每一个房间都有一个价值为Ai的宝藏, 但是每一个房间也都存在一个机关.如果小火山取走了这 ...
- NYOJ 104 最大和
最大和 时间限制:1000 ms | 内存限制:65535 KB 难度:5 描述 给定一个由整数组成二维矩阵(r*c),现在需要找出它的一个子矩阵,使得这个子矩阵内的所有元素之和最大,并把这个 ...
- [jenkins学习篇] 安装jenkins
1 下载war包,https://jenkins.io/download/ 2 安装jar包,java -jar jenkins.war 3 打开网址:http://localhost:8080 4 ...
- Flutter 发布APK时进行代码/资源混淆的坑
Flutter 发布APK时进行代码/资源混淆的坑 @author ixenos 1. 关键点 proguard是Java的代码混淆工具,但是当用第三方库的时候,必须要告诉proguard不要检查,因 ...