惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
V
Visual Studio Blog
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MongoDB | Blog
MongoDB | Blog
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Engineering at Meta
Engineering at Meta
L
LangChain Blog
Martin Fowler
Martin Fowler
GbyAI
GbyAI
博客园 - 司徒正美

博客园 - gwazy

wifi zigbee 蓝牙区别 easyui textbox 获取焦点 easyUI 异步加载树 sql 有条件计数 easyui combox 手动添加项 只有设置了 name 属性的表单元素才能在提交表单时传递它们的值 除湿方法 android 页面跳转,数据回传 android studio 乱码 android studio 工具 android 开发 简单的页面布局 android sdk 重装windows7企业版时提示“安装程序无法创建新的系统分区,也无法定位现有系统 csdn 泄露用户密码害人不浅啊。 PoolMon 使用 固态硬盘相关知识 android 平台搭建 win8 中使用第三方无线网卡出现无线连接受限解决办法 iis 故障导致网站无法访问
gridlaylout 简单布局
gwazy · 2015-04-29 · via 博客园 - gwazy
package com.example.gridlayout;


import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.Button;
import android.widget.GridLayout;


public class MainGrid extends Activity {
    GridLayout grd;
    String[] chas=new String[]
            {
              "7","8","9","*"
              ,"4","5","6","/"
              ,"1","2","3","+"
              ,"0",".","=","-"
            
            };
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main_grid);
        grd=(GridLayout)findViewById(R.id.root);
        for(int i=0;i<chas.length;i++)
        {
            Button bt=new Button(this);
             bt.setText(chas[i]);
             bt.setTextSize(40);
             bt.setHeight(200);
                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);        
                grd.addView(bt , params);

        }
    }
}
<?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:rowCount="6"
    android:columnCount="4"
    android:id="@+id/root"
    >
<!-- 定义一个横跨4列的文本框,
并设置该文本框的前景色、背景色等属性  -->
<TextView 
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_columnSpan="4"
    android:textSize="50sp"
    android:layout_marginLeft="4px"
    android:layout_marginRight="4px"
    android:padding="5px"
    android:layout_gravity="right"
    android:background="#eee"
    android:textColor="#000"
    android:text="0"/>
<!-- 定义一个横跨4列的按钮 -->
<Button 
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_columnSpan="4"
    android:text="清除"/>
</GridLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.gridlayout"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainGrid"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>