0

我的标记布局有一些问题,我没有显示 buttonBar,尽管它在代码 xml 中。请解决我的问题。

这是我的代码:

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageQuote"
    android:layout_marginTop="10dp"
    android:layout_centerHorizontal="true" />


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Description"
    android:id="@+id/descriptionOfQuote"
    android:layout_below="@+id/imageQuote"
    android:layout_marginTop="10dp"
    android:layout_centerHorizontal="true"
    android:foregroundGravity="center"
    android:textSize="22dp"/>

<LinearLayout
    android:id="@+id/buttonBar"
    android:layout_marginBottom="1dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:foregroundGravity="center"
    android:gravity="bottom"
    >
    <ImageButton
        android:layout_width="85dp"
        android:layout_height="match_parent"
        android:id="@+id/arrow_left"
        android:src="@drawable/arrow_left"
        android:background="?android:selectableItemBackground"/>
    <ImageButton
        android:layout_width="85dp"
        android:layout_height="match_parent"
        android:id="@+id/btn_copy"
        android:src="@drawable/copy"
        android:background="?android:selectableItemBackground"/>

    <ImageButton
        android:layout_width="85dp"
        android:layout_height="match_parent"
        android:id="@+id/btn_share"
        android:src="@drawable/share"
        android:background="?android:selectableItemBackground"/>

    <ImageButton
        android:layout_width="85dp"
        android:layout_height="match_parent"
        android:id="@+id/arrow_right"
        android:src="@drawable/arrow_right"
        android:background="?android:selectableItemBackground"/>

</LinearLayout>

在此处输入图像描述

如何使该按钮栏位于屏幕底部?

4

1 回答 1

0

我有两个线索可以解决你的问题:

1)使LinearLayout方向水平:

<LinearLayout
android:id="@+id/buttonBar"
android:layout_marginBottom="1dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:foregroundGravity="center"
android:gravity="bottom"
android:orientation="horizontal"
>

2)我不确定,但是buttonBar的孩子的高度可能有问题,尝试将其设置为宽度:

<ImageButton
    android:layout_width="85dp"
    android:layout_height="85dp"
    android:id="@+id/arrow_left"
    android:src="@drawable/arrow_left"
    android:background="?android:selectableItemBackground"/>

我实际上没有 Android Studio 来检查我的答案是否正确,对此感到抱歉:(

于 2016-08-20T08:28:58.920 回答