Android的TextureView
来源:互联网 发布:蓝天cpu超频软件 编辑:程序博客网 时间:2024/04/29 08:25
代码如下
<?xml version="1.0" encoding="utf-8"?><GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:columnCount="4" android:rowCount="6" android:id="@+id/root" > <TextureView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_columnSpan="4" android:layout_gravity="right" android:layout_marginLeft="4px" android:layout_marginRight="4px" android:background="#eee" android:padding="5px" android:text="0" android:textColor="#000" android:textSize="50sp" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_columnSpan="4" android:text="清除" /> </GridLayout>
package com.example.testo4;import com.example.test04.R;import android.os.Bundle;import android.app.Activity;import android.view.Gravity;import android.view.Menu;import android.widget.Button;import android.widget.GridLayout;public class MainActivity extends Activity {GridLayout gridLayout;// 定义16个按钮的文本String[] chars = new String[]{"7" , "8" , "9" , "÷","4" , "5" , "6" , "×","1" , "2" , "3" , "-","." , "0" , "=" , "+"};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);gridLayout = (GridLayout)findViewById(R.id.root);for(int i = 0 ; i < chars.length ; i++){Button bn = new Button(this);bn.setText(chars[i]);// 设置该按钮的字体大小bn.setTextSize(40);// 指定该组件所在的行GridLayout.Spec rowSpec = GridLayout.spec(i / 4 + 2);// 指定该组件所在列GridLayout.Spec columnSpec = GridLayout.spec(i % 4);GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpec , columnSpec);// 指定该组件占满父容器params.setGravity(Gravity.FILL);gridLayout.addView(bn , params);}}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}}
1 0
- Android的TextureView
- Android之TextureView浅析
- android TextureView 浅析
- Android TextureView简易教程
- Android TextureView简易教程
- Android TextureView OpenGL场景
- android-TextureView参考例子
- Android TextureView简易教程
- Android SurfaceView vs TextureView
- Android 笔记 surfaceView textureView
- Android TextureView简易教程
- TextureView VS SurfaceView-android
- Android TextureView简易教程
- Android控件--TextureView
- Android TextureView简易教程
- Android-->如何填MediaRecorder的坑(附TextureView的使用)
- Android 中的SurfaceTexture,TextureView, GLsurfaceview的区别与联系详解
- android 视频播放器 TextureView , MediaPlayer , SurfaceView 的坑
- C++动态分配内存释放内存
- 解决AndroidStudio导入工程报错:“Your project path contains non-ASCII characters.”
- HDU 3732 Ahui Writes Word(多重背包问题)
- CentOS7.1 更新 repo 源 镜像使用帮助
- 模式识别学习笔记(二)---模式相似性测度
- Android的TextureView
- 999
- 理论: 图论(6+): Dijkstra算法详解和拓展优化
- 2的1000次各位数的和
- Android中View类OnClickListener和DialogInterface类OnClickListener导入包冲突
- 第七届河南省赛 zzuoj 10401: A.物资调度 (dfs)
- 常见的DOS命令行
- hdu1518 Square--DFS
- spring+springmvc+mongodb开发环境搭建