大家好,我确实有这个:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="119dp"
android:layout_height="83dp"
android:layout_weight="0"
app:srcCompat="@drawable/icon" />
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="1"
android:layout_below="@id/imageView" // This is the solution I found which doesn't seems to work on tablerow
android:text="cccccccccccccccccccccccccccc" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="1"
android:text="Button" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="1"
android:text="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" />
<Button
android:id="@+id/button4"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="1"
android:text="ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" />
</TableRow>
</LinearLayout>
我想在ImageView下使用一个按钮,但功能“ android:layout_below =” @ id / imageView“在TableRow上不起作用。现在的样子:
所以我希望该图像位于“ CCCCCCC”按钮上方,但我无法使其正常工作
layout_below
仅用于RelativeLayout
。为了使其工作,将ImageView
和TextView
包裹到RelativeLayout
中,替换为:
<ImageView
android:id="@+id/imageView2"
android:layout_width="119dp"
android:layout_height="83dp"
android:layout_weight="0"
app:srcCompat="@drawable/icon" />
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="1"
android:layout_below="@id/imageView" // This is the solution I found which doesn't seems to work on tablerow
android:text="cccccccccccccccccccccccccccc" />
with
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="@+id/imageView2"
android:layout_width="119dp"
android:layout_height="83dp"
android:layout_weight="0"
app:srcCompat="@drawable/icon" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_below="@id/imageView" // This is the solution I found which doesn't seems to work on tablerow
android:text="cccccccccccccccccccccccccccc" />
</RelativeLayout>