×

stretchcolumns layout android

android ui开发中,tablelayout的列数是怎么计算的?android系统开发用什么工具

admin admin 发表于2022-05-12 10:19:39 浏览119 评论0

抢沙发发表评论

android ui开发中,tablelayout的列数是怎么计算的

  TableLayout,表格布局采用行列形式管理UI组件,TableLayout不需要明确地声明有多少行和列,而是通过添加TableRow、其它组件来控制表格的行数、列数。  每次向TableLayout添加一个TableRow,就是在向表格添加一行,TableRow也是容器,可以向TableRow中添加组件,每添加一个组件,即是添加一列。  如果直接向TableLayout添加组件,则认为这个组件占用一行。  表格布局中列的宽度即是每一列中最宽的组件的宽度。  使用前:  \  使用后:  \  《TableLayout  android:id=“@+id/tableLayout1“  android:layout_width=“match_parent“  android:layout_height=“wrap_content“  android:stretchColumns=“*“ 》  《TableRow  android:id=“@+id/tableRow1“  android:layout_width=“wrap_content“  android:layout_height=“wrap_content“》  《Button  android:text=“最近联系人“  android:id=“@+id/button4“  android:layout_width=“1dip“  android:layout_height=“wrap_content“》《/Button》    《Button  android:text=“联系人“  android:id=“@+id/button5“  android:layout_width=“1dip“  android:layout_height=“wrap_content“》《/Button》    《Button  android:text=“分组“  android:id=“@+id/button5“  android:layout_width=“1dip“  android:layout_height=“wrap_content“》《/Button》    《/TableRow》  《/TableLayout》  《TableLayout  android:id=“@+id/tableLayout1“  android:layout_width=“match_parent“  android:layout_height=“wrap_content“  android:stretchColumns=“*“ 》  《TableRow  android:id=“@+id/tableRow1“  android:layout_width=“wrap_content“  android:layout_height=“wrap_content“》  《Button  android:text=“最近联系人“  android:id=“@+id/button4“  android:layout_width=“1dip“  android:layout_height=“wrap_content“》《/Button》    《Button  android:text=“联系人“  android:id=“@+id/button5“  android:layout_width=“1dip“  android:layout_height=“wrap_content“》《/Button》    《Button  android:text=“分组“  android:id=“@+id/button5“  android:layout_width=“1dip“  android:layout_height=“wrap_content“》《/Button》    《/TableRow》  《/TableLayout》  TableLayout 增加一个属性 android:stretchColumns=“*“ 表示所有列都要自动拉伸,以便适应屏幕宽度。  它的值即可以是数字,也可以是*,注意数字是从0开始的,即:android:stretchColumns=“1“ 是设置 TableLayout所有行的第二列为扩展列。  上面我们会看到 第1列的按钮比其他列的按钮要宽,如果我们想都一样宽如何办呢?  一个简单办法:  android:layout_width=“1dip“

android系统开发用什么工具

  android是基于linux的,所以在ubuntu下是最好的。当然windows下面也是可以的。但是android的内核是基于linux的,并且通过终端进行各种操作,非常强大,也比cmd方便。ubuntu系统,以前是windows然后安装了ubuntu的虚拟机。android大部分的开发都是中间层到顶层的应用开发,所以基本上是java开发。表配如下:1。eclipse是开发java必备,也是android必备。(当然前提是先安装JDK1.6)2。下载android的SDK和ADT。这是android的开发必须的工具,adb、ddms、mksdcard、aapt,debug 必备A。安装完eclipse后,通过help=〉install new software 。。把ADT安装好B。然后window=》preference设置好SDK的路径即可如果用到C开发的话,可以安装一下啊CDT现在可以通过AVD manager安装一下你想在哪个平台下的api,比如:android2.3.4,就可以建一个2.3.4的emulator,把模拟器跑起来。通过adb ddms 等工具察看、开发了。为了方便,把adb的路径加到环境变量里。

Android怎么实现Linearlayout的垂直分割线

方法一:使用一个View设置background属性放置在两个控件之间

《LinearLayout xmlns:android=“    xmlns:tools=“    android:layout_width=“match_parent“    android:layout_height=“match_parent“    android:gravity=“center“    android:orientation=“horizontal“ 》    《Button        android:id=“@+id/button1“        android:layout_width=“wrap_content“        android:layout_height=“wrap_content“        android:text=“Button“ /》    《View         android:layout_width=“1dp“        android:layout_height=“match_parent“        android:background=“@drawable/divider“/》    《Button        android:id=“@+id/button2“        android:layout_width=“wrap_content“        android:layout_height=“wrap_content“        android:text=“Button“ /》《/LinearLayout》

但是这个有明显的缺点就是需要手动去添加一个View很繁琐

方法二:Android3.0及以上版本使用LinearLayout的android:showDividers属性

android:showDividers属性可以设置如下4个值:

none:不显示分隔线;

beginning:在LinearLayout的开始处显示分隔线;

end:在Linearlayout的结尾处显示分隔线;

middle:在LinearLayout中的每两个组件间显示分隔线

还要设置分割线的图片android:divider属性

《LinearLayout xmlns:android=“    xmlns:tools=“    android:layout_width=“match_parent“    android:layout_height=“wrap_content“    android:showDividers=“middle“    android:divider=“@drawable/divider“    android:gravity=“center“    android:orientation=“horizontal“ 》    《Button        android:id=“@+id/button1“        android:layout_width=“wrap_content“        android:layout_height=“wrap_content“        android:text=“Button“ /》    《Button        android:id=“@+id/button2“        android:layout_width=“wrap_content“        android:layout_height=“wrap_content“      		android:text=“Button“ /》    《Button        android:id=“@+id/button3“        android:layout_width=“wrap_content“        android:layout_height=“wrap_content“        android:text=“Button“ /》    《Button        android:id=“@+id/button4“        android:layout_width=“wrap_content“        android:layout_height=“wrap_content“        android:text=“Button“ /》    《Button        android:id=“@+id/button5“        android:layout_width=“wrap_content“        android:layout_height=“wrap_content“        android:text=“Button“ /》《/LinearLayout》

可以看到每个button之间都有了分割线