简体   繁体   English

放置项目布局,未显示buttonBar

[英]Placing a layout of items, not shown buttonBar

I have some problems with the marking layout, I have not shown the buttonBar, although it is in the code xml. 我在标记布局方面遇到了一些问题,尽管它在代码xml中,但我没有显示buttonBar。 Please solve my problem. 请解决我的问题。

This is my code: 这是我的代码:

<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>

enter image description here 在此处输入图片说明

How to make that buttonBar was at the bottom of the screen? 如何使buttonBar位于屏幕底部?

I have two clues that can solve your problem: 我有两条线索可以解决您的问题:

1) make LinearLayout orientation horizontal: 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) I am not sure but there could be a problem with height of children of buttonBar, try to set it as width: 2)我不确定,但是buttonBar的子代的高度可能有问题,请尝试将其设置为width:

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

I actually do not have Android Studio to check if my answer is correct, sorry for that :( 我实际上没有Android Studio来检查我的答案是否正确,对此表示抱歉:(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM