Android动态布局控制
来源:互联网 发布:淘宝怎么不能买wlan了 编辑:程序博客网 时间:2024/06/11 06:01
XML
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ToggleButton android:id="@+id/toggle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOff="横向排列" android:textOn="纵向排列" android:checked="true"/> <Switch android:id="@+id/switcher" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOff="横向排列" android:textOn="纵向排列" android:thumb="@mipmap/bt4" android:checked="true"/> <LinearLayout android:id="@+id/test" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="测试案件一" android:orientation="vertical" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="测试案件二" android:orientation="vertical" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="测试案件三" android:orientation="vertical" /> </LinearLayout></LinearLayout>MainActivity:
package learn.li.com.learnthree;import android.os.Handler;import android.os.Message;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.Gravity;import android.widget.Button;import android.widget.CompoundButton;import android.widget.GridLayout;import android.widget.LinearLayout;import android.widget.RadioGroup;import android.widget.Switch;import android.widget.TextView;import android.widget.ToggleButton;import java.util.Timer;import java.util.TimerTask;public class MainActivity extends AppCompatActivity { ToggleButton toggle; Switch switcher; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toggle = (ToggleButton)findViewById(R.id.toggle); switcher = (Switch)findViewById(R.id.switcher); final LinearLayout test = (LinearLayout)findViewById(R.id.test); CompoundButton.OnCheckedChangeListener listener = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ test.setOrientation(1); toggle.setChecked(true); switcher.setChecked(true); }else{ test.setOrientation(0); toggle.setChecked(false); switcher.setChecked(false); } } }; toggle.setOnCheckedChangeListener(listener); switcher.setOnCheckedChangeListener(listener); }}
0 0
- Android动态布局控制
- Android的布局控制
- [Android]代码控制布局
- Android 控制比例布局
- Android 动态布局 (代码布局)
- Android 动态加载布局
- Android 动态更改布局
- Android 动态加载布局
- android 动态布局
- Android 动态加载布局
- android动态界面布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- android 动态布局
- Android 动态加载布局
- 深层神经网络进行Gradient Check的时候注意delta的大小
- CentOS7.2安装KVM虚拟机
- 阿里巴巴Java开发手册
- 本金存款利率的计算
- [Spark]Spark 应用程序部署工具spark-submit
- Android动态布局控制
- Android使用MediaRecorder和Camera实现视频录制及播放功能整理
- linux c之strncpy函数和strncmp函数最简单使用总结
- Java温习——SUN公司和Java平台
- centos服务器搭建
- Ural 2063 Black and White【有意思】
- C语言 大小写字母的替换
- 机器学习12推荐系统
- JS实现页面加载完毕之前loading提示效果