Android Gallery layout布局

妖怪 2011-01-31 03:50:30
需要在一个屏幕上面实现类似布局

------------------------------
TextView
------------------------------
Gallery




------------------------------
LinearLayout
ImageView ImageView
------------------------------

但是gallery必须设置为fill_parent
请问有没有比较合适的layout可以使用

都使用LinearLayout之后 gallery会没有滑动效果
如果XML可用 立即结贴给分
...全文
1094 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
男主角 2011-04-02
  • 打赏
  • 举报
回复
其实,想不写死的话,在程序里用代码实现,移植性好。也不复杂。
男主角 2011-04-02
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 lulongjun2007 的回复:]
还是有些不一样,你给的配置Gallery高度是写死的,楼主给的是动态按内容处理的,具体的我还没试验,路过打酱油中。。。期待结论,我是个懒人哈
[/Quote]


提供思路。
木不且八 2011-04-02
  • 打赏
  • 举报
回复
还是有些不一样,你给的配置Gallery高度是写死的,楼主给的是动态按内容处理的,具体的我还没试验,路过打酱油中。。。期待结论,我是个懒人哈
妖怪 2011-04-02
  • 打赏
  • 举报
回复
最后还是用了android里面对layout的height的判断来做的
在里面最后才计算gallery的高度 这样才行

看来还是要看代码是王道
男主角 2011-04-01
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "@+id/layout_root"
android:orientation = "vertical"
android:layout_width="320dip"
android:layout_height="480dip">
<TextView android:text="请输入账号" android:id="@+id/account_view" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#FFFFFF"
android:textSize = "28dip" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" ></TextView>
<Gallery
android:layout_width="fill_parent"
android:layout_height="200dip"
android:background="@drawable/icon"
android:layout_marginTop="10dip"> </Gallery>
<TextView android:text="请输入密码" android:id="@+id/paw_view" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textSize = "28dip" android:background="#FFFFFF" android:singleLine="false"></TextView>
<LinearLayout android:layout_width="wrap_content" android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation = "horizontal"
android:layout_marginBottom = "20dip" android:layout_marginTop = "20dip">
<ImageButton android:layout_width="wrap_content" android:src="@drawable/icon" android:id="@+id/login_ok" android:layout_height="50dip"
></ImageButton>
<ImageButton android:layout_width="wrap_content" android:src="@drawable/icon" android:id="@+id/login_back" android:layout_height="50dip"
android:layout_marginLeft = "70dip" android:layout_marginRight = "10dip"></ImageButton>
</LinearLayout>
</LinearLayout>



这是根据我的图片,大致弄的。我看你明明都知道啊。。

给我分吧,你看我容易吗
男主角 2011-04-01
  • 打赏
  • 举报
回复
你自己明明都知道,为什么还要问呢?我好纠结
男主角 2011-04-01
  • 打赏
  • 举报
回复
我已经实现了你要的布局

呵呵。
youngwolf 2011-04-01
  • 打赏
  • 举报
回复
关键点是,LinearLayout要是:
android:layout_height="wrap_content"

那么Gallery也可以是:
android:layout_height="fill_parent"
youngwolf 2011-04-01
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>

<Gallery
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
/>

</LinearLayout>

上面的试过了,有滑动效果啊。
youngwolf 2011-04-01
  • 打赏
  • 举报
回复
我自己试的结果,怎么只要有Gallery,其它控件都不可见了!
妖怪 2011-04-01
  • 打赏
  • 举报
回复
这样TextView会跟着移动么?
s278777851 2011-02-11
  • 打赏
  • 举报
回复

<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView></TextView>
<Gallery android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
</Gallery>
</LinearLayout>


公司项目截的, 只给架构

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧