2014-08-11 3 views
0

나는 간단한 액션 바를 가지고 있는데, 그것은 두 개의 ImageButtonButton을 포함하고있다. 문제는 ImageButton의 이미지가 정확하게 막대의 중앙에 있지 않음입니다. Button이 없으면 액션 바 자체가 완벽하게 감싸기 때문에 정렬 된 것처럼 보입니다. 그러나 Button을 소개 할 때 ImageButton은 막대의 천장에 달라 붙는 것처럼 보입니다.
여기 내 xml 파일동일한 작업 표시 줄에서 ImageButton과 Button을 정렬하는 방법은 무엇입니까?

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

입니다 그리고 여기에 활동의 Screenshot입니다합니다 ('좋아요'와 '댓글'아이콘 수평 텍스트 "37 코멘트"로 정렬되어야합니다) 내 당신의 XML 코드를 이해에 따라이하여 ImageButton 태그의

+0

이미지를 게시하는 데 최소한 10 명이 필요한 이유는 무엇입니까? –

답변

0

사용 중력 당신이 centerVetical

로에 중력을 줄 필요가 귀하의 요구 사항에 적합
 <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"/> 
+0

'ImageButton'에 대한 해결책을 찾았을 때 작동하는 것처럼 보였습니다. 그러나 둘 다 정렬하려고 시도했을 때 [result] (http://imgur.com/NWSjcNr)는 다소 이상했습니다. –

+0

그런 다음 안드로이드를 사용해야한다고 생각합니다 : 두 이미지 뷰에서 layout_height = "match_parent"를 사용하여 이미지 소스를 이미지 입력 ​​원으로 사용하십시오. 위의 라인은 그냥 시도해보십시오. –

+0

android : layout_height = "match_parent" –

관련 문제