【发布时间】:2014-04-23 08:49:42
【问题描述】:
我见过这种布局 (http://cdn0.tnwcdn.com/wp-content/blogs.dir/1/files/2014/03/Instaedit1.jpg),我想做类似的事情,但我不知道我必须做什么才能获得这个结果。 我尝试过包含一个 imageview 和一个包含三个 imagebutton 的 gridlayout 的相对布局。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.prova.MainActivity$PlaceholderFragment" xmlns:app="http://schemas.android.com/apk/res/com.example.prova">
<ImageView
android:id="@+id/imageView1"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/profile" />
<android.support.v7.widget.GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView1"
app:columnCount="3"
app:orientation="horizontal"
app:rowCount="1"
app:useDefaultMargins="false" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_gravity="fill_horizontal"
android:scaleType="center"
android:src="@drawable/friend" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_gravity="fill_horizontal"
android:maxHeight="100dp"
android:src="@drawable/fotocamera" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/eventi" />
</android.support.v7.widget.GridLayout>
</RelativeLayout>
但我没有获得图像顶部的相同结果。 我试过改变重力值和宽度值,但没有。 你能帮助我吗??? (对不起我的英语不好:P 谢谢)。
【问题讨论】:
-
你的结果是什么?可能会发布截图,因为布局相当复杂。
-
你到底想达到什么目标?
-
这是it.tinypic.com/r/2rf9fdf/8的结果@gridlayout中的三个图像按钮没有占据所有水平空间。
标签: android xml android-layout layout android-gridlayout