初学Android,GridLayout布局,为什么界面总是超出屏幕?这是Layout的xml文件,求大神指点。。

l2190215487 2016-07-17 06:38:15
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Choose an Image" />
<Button
android:id="@+id/loadPhotoButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Load New Photos"/>

<GridLayout
android:layout_below="@id/textView1"
android:layout_above="@id/loadPhotoButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="3" >
<ImageView
android:id="@+id/imageView1"
android:src="@drawable/logo" />
<ImageView
android:id="@+id/imageView2"
android:src="@drawable/logo" />
<ImageView
android:id="@+id/imageView3"
android:src="@drawable/logo" />

</GridLayout>


</RelativeLayout>
...全文
720 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
tudouzi007 2016-07-19
  • 打赏
  • 举报
回复
引用 7 楼 l2190215487 的回复:
[quote=引用 3 楼 tudouzi007 的回复:] 原因猜测是你的logo图片太大了,3张横着放放不下所以超出屏幕了
是图片的问题?那我只能去修改图片了?有没有办法让通过程序让它自己调整呢?[/quote] 把GridLayout 换成LinearLayout,然后设置 android:layout_weight="1" ,3等分就行了 <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/loadPhotoButton" android:layout_below="@id/textView1" android:orientation="horizontal" > <ImageView android:id="@+id/imageView1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/aaa" /> <ImageView android:id="@+id/imageView2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/aaa" /> <ImageView android:id="@+id/imageView3" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/aaa" /> </LinearLayout>
哎,真难 2016-07-18
  • 打赏
  • 举报
回复
这样看没有问题,但是应该是图片没设置宽高
tudouzi007 2016-07-18
  • 打赏
  • 举报
回复
原因猜测是你的logo图片太大了,3张横着放放不下所以超出屏幕了
tudouzi007 2016-07-18
  • 打赏
  • 举报
回复
imageview里不写width和height属性真的可以么
l2190215487 2016-07-18
  • 打赏
  • 举报
回复
引用 3 楼 tudouzi007 的回复:
原因猜测是你的logo图片太大了,3张横着放放不下所以超出屏幕了
是图片的问题?那我只能去修改图片了?有没有办法让通过程序让它自己调整呢?
l2190215487 2016-07-18
  • 打赏
  • 举报
回复
引用 2 楼 tudouzi007 的回复:
imageview里不写width和height属性真的可以么
我一开始也奇怪这个问题,后来发现在网格布局下真的可以不写的。。
l2190215487 2016-07-18
  • 打赏
  • 举报
回复
引用 1 楼 under_wind 的回复:
超出屏幕?我这边显示不会啊,横向的三个图片
我的真的会,三星note4真机调试,确实超出边框了
under_wind 2016-07-17
  • 打赏
  • 举报
回复
超出屏幕?我这边显示不会啊,横向的三个图片

80,351

社区成员

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

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