展会信息港展会大全

android中的ImageButton,RadioGroup,CheckBox,ToggleButton
来源:互联网   发布日期:2015-12-07 15:32:35   浏览:1417次  

导读:activity_main.xml的配置: [html] LinearLayout xmlns:android=http://schemas.android.com/apk/res/android xmlns:tools=http://schemas.android.com/tools android:id=@+id/LinearLayout1 android:layout_width=match_parent android:layout_height=match...

activity_main.xml的配置:

[html]

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/LinearLayout1"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/hello_world"

tools:context=".MainActivity" />

<!-- 图片按钮 -->

<ImageButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/home"

android:contentDescription="@string/imagetext"

/>

<!-- 按钮中加图片和文字 -->

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/textbtn"

android:drawableRight="@drawable/home"<!-- 这里的home是在res目录下文件夹drawable中的一张图片,具体哪个drawable应该都可以的 -->

/>

<!-- Radio组,单选按钮 -->

<RadioGroup

android:layout_width="wrap_content"

android:layout_height="wrap_content"

>

<RadioButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/nan"

/>

<RadioButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/nv"

/>

</RadioGroup>

<!-- 开关状态按钮 -->

<ToggleButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textOff="打开"

android:textOn="关闭"

/>

<!-- checkbox 多选按钮 -->

<CheckBox

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="1.江西"

/>

<CheckBox

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="2.福建"

/>

<CheckBox

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="1.浙江"

/>

</LinearLayout>

strings.xml中主要配置写文本的信息:

[html]

<resources>

<string name="app_name">ImageButton</string>

<string name="hello_world">图片按钮</string>

<string name="menu_settings">Settings</string>

<string name="title_activity_main">MainActivity</string>

<string name="imagetext">这是图片按钮</string>

<string name="textbtn">按钮文字</string>

<string name="nan">男</string>

<string name="nv">女</string>

</resources>

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港