Android 如何将ImageButton与同一操作栏中的按钮对齐?

Android 如何将ImageButton与同一操作栏中的按钮对齐?,android,button,Android,Button,我有一个简单的操作栏,它包含两个ImageButtons和一个按钮。问题是ImageButtons中的图像并不完全位于条形图的中心。没有按钮,它们看起来是对齐的,因为动作栏本身完美地围绕着它们。但当我介绍一个按钮时,图像按钮似乎粘在了酒吧的天花板上。 这是我的.xml文件 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.co

我有一个简单的操作栏,它包含两个ImageButtons和一个按钮。问题是ImageButtons中的图像并不完全位于条形图的中心。没有按钮,它们看起来是对齐的,因为动作栏本身完美地围绕着它们。但当我介绍一个按钮时,图像按钮似乎粘在了酒吧的天花板上。 这是我的.xml文件

<FrameLayout 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"
android:background="#0099cc"
tools:context="com.convo.imgfs.FullscreenActivity">


<!-- The primary full-screen view. This can be replaced with whatever view
     is needed to present your content, e.g. VideoView, SurfaceView,
     TextureView, etc. -->
<ImageView
    android:id="@+id/fullscreen_content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/bg_image"
    android:scaleType = "centerCrop"/>
<!-- This FrameLayout insets its children based on system windows using
     android:fitsSystemWindows. -->
<FrameLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <LinearLayout android:id="@+id/fullscreen_content_controls"
        style="?metaButtonBarStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center_horizontal"
        android:background="@color/black_overlay"
        android:orientation="horizontal"
        tools:ignore="UselessParent">

        <ImageButton
            android:id="@+id/likes_button"
            android:src="@drawable/likes_imgbutton"
            android:background="@android:color/transparent"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:scaleType="fitCenter"
            android:layout_weight="1"/>

        <ImageButton
            android:id="@+id/comments_button"
            android:src="@drawable/comments_imgbutton"
            android:background="@android:color/transparent"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:scaleType="fitCenter"
            android:layout_weight="1"/>

        <Button
            style="?metaButtonBarButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scaleType="fitCenter"
            android:text="37 comments"
            android:id="@+id/show_comments_button"
            android:layout_weight="2"/>

    </LinearLayout>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Done"
        android:id="@+id/done_button"
        android:layout_gravity="right|top" />
</FrameLayout>

这里是活动的一部分,“喜欢”和“评论”图标应该和文本水平对齐37条评论

在这个图像中使用重力按钮标记据我所知,您的xml代码非常适合您的要求,只是您需要将重力作为中心


为什么至少需要10个代表才能发布图像?当我为任何一个ImageButton尝试您的解决方案时,它看起来都很有效,但当我尝试将两者对齐时,感觉很奇怪。然后我认为您需要在两个图像视图中使用android:layout\u height=match\u parent,因为不管怎样,您将源代码作为imageButton的输入,希望上面这一行可以工作,请尝试itandroid:layou\u height=match\u parents,但没有效果。图标仍然拥挤。:ooppppppppssssss
        <ImageButton
            android:id="@+id/comments_button"
            android:src="@drawable/comments_imgbutton"
            android:background="@android:color/transparent"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:scaleType="fitCenter"
            android:layout_weight="1"/>