2017-07-28 5 views
1

同じパディングの行に3つのフローティングアクションボタンを配置したいと思います。結果は次のようになります。 How it should lookLinearLayoutポジション3つのボタンの間に同じパディングがあります

しかし、今のところ、それはHow it look right now(その中間キャプチャFABは表示されません)のように見えます。あなたがそこに見ることができますが、それだけでは動作しませんようlayout_weight:私はアンドロイドを設定しようとしました

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" > 

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/relativeLayoutCamera2"> 

     <TextureView 
      android:id="@+id/textureView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     <LinearLayout 
      android:gravity="bottom" 
      android:layout_alignParentBottom="true" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:id="@+id/baseline" 
      android:weightSum="3" 
      android:background="@color/strapGrey"> 

      <android.support.design.widget.FloatingActionButton 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:id="@+id/browseImagesFAB" 
       android:src="@drawable/ic_photo_library_white_24dp" 
       app:elevation="0dp" 
       android:layout_weight="1" 
       android:paddingTop="10dp" 
       android:paddingBottom="10dp" 
       app:backgroundTint="@color/strapGrey" 
       app:fabSize="mini"/> 

      <android.support.design.widget.FloatingActionButton 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:id="@+id/captureInvisible" 
       android:src="@drawable/ic_photo_camera_white_24dp" 
       app:fabSize="mini" 
       android:layout_gravity="center_horizontal" 
       android:layout_weight="1" 
       android:paddingTop="10dp" 
       android:paddingBottom="10dp" 
       app:backgroundTint="@color/strapGrey" /> 

      <android.support.design.widget.FloatingActionButton 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:id="@+id/flashFAB" 
       android:src="@drawable/ic_flash_off_white_24dp" 
       app:elevation="0dp" 
       android:layout_weight="1" 
       android:paddingTop="10dp" 
       android:paddingBottom="10dp" 
       app:backgroundTint="@color/strapGrey" 
       app:fabSize="mini"/> 

     </LinearLayout> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/captureImageFAB" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="@dimen/fab_margin" 
      android:src="@drawable/ic_photo_camera_white_24dp" 
      app:fabSize="normal" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" /> 

    </RelativeLayout> 

</android.support.design.widget.CoordinatorLayout> 

は、ここに私のレイアウトファイルです。助けてください!

+1

短い答えは 'FloatingActionButton'が持つ素敵を果たしていないということであるように結果が見えるはずですLinearLayout代わりに 'CircleImageView'を使ってみてください。 – privatestaticint

答えて

0

これは、あなたのデザイン

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<android.support.design.widget.FloatingActionButton 
    android:layout_width="60dp" 
    android:layout_height="60dp" 
    android:layout_gravity="bottom|center_horizontal" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/bottom_nav_height" 
    android:layout_gravity="bottom" 
    android:background="#757575" 
    android:weightSum="3"> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_weight="1" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/iv_nav_voucher" 
      android:layout_width="24dp" 
      android:layout_height="24dp" 
      android:layout_gravity="center" 
      android:clickable="false" 
      android:focusableInTouchMode="false" 
      android:src="@drawable/ic_launcher" /> 
    </LinearLayout> 

    <View 
     android:id="@+id/nav_center" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:gravity="center" 
     android:orientation="horizontal"></View> 

    <LinearLayout 
     android:id="@+id/nav_other" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:gravity="center" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/iv_nav_other" 
      android:layout_width="24dp" 
      android:layout_height="24dp" 
      android:clickable="false" 
      android:focusableInTouchMode="false" 
      android:src="@drawable/ic_launcher" /> 
    </LinearLayout> 
</LinearLayout> 

を実装する非常に単純な例であり、この enter image description here

+0

@ dimen/bottom_nav_heightの値は何ですか? – peterrojs

+0

ああ。ボトムナビゲーションのデフォルト高さ:56dp。それを56dpまたは任意の値に変更してください –

+0

もう1つ質問があります。最初のLinearLayoutが基本的に2つのImageViewがあるナビゲーションバーである場合、そのViewオブジェクトは何ですか? – peterrojs

1
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.vzw.www.myapplication.MainActivity" 
android:gravity="center"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:padding="5dp"> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button 1" 
     android:layout_weight="0.33"/> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button 1" 
     android:layout_weight="0.33"/> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button 1" 
     android:layout_weight="0.33"/> 


</LinearLayout> 

これは、この>

enter image description here

ようになります。また、彼らはBUTTONSする必要がいけません。 ImageViewsやTextViewsでも同じことができます。

関連する問題