网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

android编程—界面横竖向切换

时间:2024-10-12 04:53:34

1、首先打开Android编程工具,其实无所谓哪一种工具,我用的Eclipse

2、先添加几个控件,设置为垂直显示,代码如下<L坡纠课柩inearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".MainActivity" > <ToggleButton android:id="@+id/toggle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOff="水平分布" android:textOn="垂直分布" android:checked="true" /> <LinearLayout android:id="@+id/test" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第一个按钮"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第二个按钮"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第三个按钮"/> </LinearLayout></LinearLayout>显示效果,如图显示

android编程—界面横竖向切换
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com