AndroidDev 板


LINE

※ 引述《hhhhomerun (homerun)》之铭言: : ┌────────────┐ : │┌───┐ ┌───┐│ 大家好我是一个初学新手,想要设计 : ││Button│ │Button││ : │└───┘ └───┘│ 出这样的一个画面,就是在一个页里,最 : │┌──┐┌──┐┌──┐│ : ││tab1││tab2││tab3││ 顶端是两个Button,然後下面是书签页, : ││ └───────┐│ : ││ ││ 上网有找到书签页的教学,也把书签页做 : ││ ││ : ││ ││ 出来了,可是button就摆不上去了,做不 : ││ ││ : ││ ││ 出那样的版型 : ││ ││ : ││ ││ 希望能请前辈们指导,衷心感谢! : ││ ││ : ││ ││ : │└──────────┘│ : └────────────┘ 图画的不错 不知道是不是长这样? http://uploadingit.com/file/lwajzo7l2qyreq9i/Tablayout.PNG
如果是, 参考档案在这XD http://uploadingit.com/file/6sb8wcx1ymdqiu7d/TestLayout.zip 其实想法很简单 我把要呈现的layout分成两部分 其中一部分是上面的两个button,其中一个靠左 一个靠右 另外一部分是下面的tabwidget 所以是这样的 先用tablelayout把两个button包起来 然後tabwidget用tabhost包起来 然後再用linearlayout把tablelayout跟tabhost包起来 XML如下 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TableLayout android:stretchColumns="0" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_gravity="left" ></Button> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button2" ></Button> </TableRow> </TableLayout> <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" /> </LinearLayout> </TabHost> </LinearLayout> 参考看看 --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.221.115.4 ※ 编辑: givemepass 来自: 61.221.115.4 (09/05 17:01)
1F:推 sorrel20567:推,想请问一下,tablelayout有没有办法让两个button 09/05 18:00
2F:→ sorrel20567:不要离那麽开,就是贴着正中间的线,一个button靠线左 09/05 18:00
3F:→ sorrel20567:一个button靠线右, 我试了很久都排不出想要的样子 09/05 18:01
4F:→ sorrel20567:用linear的margin又很怕手机解析度不同而跑掉 09/05 18:01
http://uploadingit.com/file/gg75nzowlaz3wc1f/TestLayout.png
这样? 用LinearLayout的 android:layout_weight属性 假设button1 属性为1 button2属性为2 则 button1的大小就是 1/(1+2) 同理 假设你要两个大小一样 则 两个数值都设定相同 就可以了
5F:推 hhhhomerun:谢谢你 後来我发现我的问题了 因为我一直用droiddraw在 09/05 20:12
6F:→ hhhhomerun:做版型 结果droiddraw的tabhost只能当作主架构大框不能 09/05 20:13
7F:→ hhhhomerun:像其他layout那样另外拉进去所以就卡住了.. 後来弄了好 09/05 20:14
8F:→ hhhhomerun:久去XML里面删删弄了半天(真的半天)改改终於有弄出来了 09/05 20:15
9F:→ hhhhomerun:谢谢你! 09/05 20:15
※ 编辑: givemepass 来自: 61.221.115.4 (09/06 08:39)







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Boy-Girl站内搜寻

TOP