首页 技术 正文
技术 2022年11月9日
0 收藏 819 点赞 1,129 浏览 2827 个字

1、

package com.fish.helloworld;import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;public class MainActivity extends Activity { private ImageView m_ImageView;
private TextView m_TextView;
private float m_AlphaValue; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_key); m_ImageView = (ImageView)findViewById(R.id.imageView1);
m_TextView = (TextView)findViewById(R.id.textView1);
m_AlphaValue = 0xFF; m_ImageView.setAlpha(m_AlphaValue);
m_TextView.setText("Alpha = " + m_AlphaValue * 100 / 0xff + "%");
} @Override
public boolean onKeyDown(int keyCode, KeyEvent msg){ Log.v("KeyCode","KeyCode = " + keyCode);
Log.v("msg","msg = " + msg); switch(keyCode){
case KeyEvent.KEYCODE_VOLUME_UP:
m_AlphaValue += 20;
break;
case KeyEvent.KEYCODE_VOLUME_DOWN:
m_AlphaValue -= 20;
break;
default:
break; } if(m_AlphaValue >= 0xFF) m_AlphaValue = 0xFF;
if(m_AlphaValue <= 0x00) m_AlphaValue = 0x0; m_ImageView.setAlpha(m_AlphaValue);
m_TextView.setText("Alpha = " + m_AlphaValue * 100 / 0xff + "%"); return super.onKeyDown(keyCode, msg);
}
}

2、

<?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" > <TextView
android:id="@+id/textView1"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_weight="0.03"
android:text="TextView" /> <ImageView
android:id="@+id/imageView1"
android:layout_width="241dp"
android:layout_height="195dp"
android:layout_marginRight="37dp"
android:layout_marginTop="176dp"
android:layout_weight="0.06"
android:src="@drawable/ic_launcher" /></LinearLayout>

3、触摸屏

package com.fish.helloworld;import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;public class MainActivity extends Activity { private TextView m_TextView;
private TextView m_TextView2; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.skeleton_activity); m_TextView = (TextView)findViewById(R.id.textView1);
m_TextView2 = (TextView)findViewById(R.id.textView2); } @Override
public boolean onTouchEvent(MotionEvent event){ int action = event.getAction();
float x = event.getX();
float y = event.getY(); m_TextView.setText("Action = " + action);
m_TextView2.setText(x + " + " + y); return true;
}}

4、

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,557
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898