2016-08-30 1 views
0

アクティビティにTablayoutを表示してから、そのTabLayoutを右揃えにするImageButtonを表示するとします。私はこれには以下のレイアウトを使用していますが、タブが正しく表示されず、最後のタブが切り取られています。 TabLayoutの後にスクロール可能なタブとImageButtonを表示したい。アンドロイドでTabLayoutの右にビューを整列する

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_marginLeft="@dimen/margin_5dp" 
android:layout_marginStart="@dimen/margin_5dp" 
android:layout_marginRight="@dimen/margin_5dp" 
android:layout_marginEnd="@dimen/margin_5dp" 
android:background="@color/white" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.TabLayout 
    android:id="@+id/tabs" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:tabMode="scrollable" 
    app:tabGravity="center" 
    android:background="@color/gray_background" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<ImageButton 
    android:background="@color/gray_background" 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:scaleType="center" 
    android:id="@+id/add_sticker_store" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" 
    android:layout_marginLeft="@dimen/margin_5dp" 
    android:src="@drawable/ic_action_new"/> 


<android.support.v4.view.ViewPager 
    android:layout_below="@id/tabs" 
    android:id="@+id/viewpager" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/gray_background" 
    android:layout_alignParentBottom="true"/> 

<View 
    android:layout_width="match_parent" 
    android:layout_height="2dp" 
    android:layout_below="@id/tabs" 
    android:background="@color/white"/> 

最後のタブがクロップ取得されたビューのスクリーンショットを確認してください。もし誰かがこれを達成する方法を知っていれば助けてください。 enter image description here

ありがとうございました。

答えて

0

TabLayoutとImageButtonの間にルールを追加します。

<ImageButton 
    android:background="@color/gray_background" 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:scaleType="center" 
    android:id="@+id/add_sticker_store" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" 
    android:layout_marginLeft="@dimen/margin_5dp" 
    android:src="@drawable/ic_action_new"/> 

<android.support.design.widget.TabLayout 
    android:id="@+id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:tabMode="scrollable" 
    app:tabGravity="center" 
    android:background="@color/gray_background" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_toLeftOf="@+id/add_sticker_store" /> 
+0

を発行解決だと思う、それはTabLayoutとImageButtin間のルールを追加した後、今取り組んでいる、お返事ありがとうございました。どうもありがとう。 :) –

0

私は、これはあなたが

<?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" 
    android:layout_marginLeft="5dp" 
    android:layout_marginStart="5dp" 
    android:layout_marginRight="5dp" 
    android:layout_marginEnd="5dp" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/ll"> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_weight="9" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      app:tabMode="scrollable" 
      app:tabGravity="center" 
      android:background="@color/colorAccent" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" /> 

     <ImageButton 
      android:layout_weight="1" 
      android:background="@color/colorAccent" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:scaleType="center" 
      android:id="@+id/add_sticker_store" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" 
      android:layout_marginLeft="5dp"/> 


    </LinearLayout> 


    <android.support.v4.view.ViewPager 
     android:layout_below="@id/ll" 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/colorAccent" 
     android:layout_alignParentBottom="true"/> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="2dp" 
     android:layout_below="@id/ll" 
     android:background="@color/colorPrimaryDark"/> 

    </RelativeLayout> 
関連する問題