GridLayout
我很弱,通常我做的是使用LinearLayout
来做我的界面,但今天我想试试Gridlayout
。
我一直在研究Gridlayout
一段时间,只是不明白它,不理解背后的逻辑。
我希望创建一个简单的Gridlayout
来存储我的对象,如下所示,有人可以告诉我该怎么做吗?
或者可能Gridlayout
不能这样做???
答案 0 :(得分:3)
也许你可以这样做:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:layout_width="170dp"
android:layout_height="200dp"
android:id="@+id/imageButton"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="170dp"
android:layout_height="200dp"
android:id="@+id/imageView"
android:layout_below="@+id/imageButton"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="TEXTT"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignBottom="@+id/imageView"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/imageButton" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView2"
android:layout_below="@+id/imageView"
android:layout_alignParentStart="true" />
</RelativeLayout>
如果这不是您想要的,那么我可以尝试帮助您:)
答案 1 :(得分:0)
我建议你使用RelativeLayout:
<RelativeLayout>
<ImageButton id="@+id/img1"
alignParentTop="true"
alignparentLeft="true" />
<ImageButton layout_below="@id/img1"
alignparentLeft="true" />
<TextView alignParentRight="true"
alignParentTop="true" />
<ImageView alignParentBottom="true" />
</RelativeLayout>
您需要调整宽度和高度以满足您的要求