2017-01-03 2 views
0

私はtablayoutとviewpagerを持つヘッダーを持っていますが、ビューページャには別の断片があります。最初の断片は地図を示しています。 私が持っている問題は、それが大きな画面でレイアウトが機能しないということです。実際には、ビューページの上部に空き領域があります。ビューページの重みを大きくすると、その空き領域がカバーされます。 私はsumweightは、すべての重みの和であるが、それはここで働いていないことを知っている:あなたはRelativeLayoutでそれを使用することはできませんのでLinearLayout Weightsumは機能しません

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    tools:context="com.example.noavaran.drugstore.Activity.MainPageActivity" 
    android:background="@android:color/transparent" 
    android:layoutDirection="rtl" 
    android:orientation="vertical"> 


    <LinearLayout 
     android:weightSum="100" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 
     <RelativeLayout 

      android:layout_weight="12" 
      android:id="@+id/header_section" 
      android:layout_width="match_parent" 
      android:layout_height="0dp"> 
      <RelativeLayout 
       android:id="@+id/layout_container" 
       android:orientation="horizontal" 
       android:layout_alignParentTop="true" 
       android:layout_width="match_parent" 
       android:background="@color/color_main" 
       android:layout_height="@dimen/Tab_Head_height"> 
       <ImageView 

        android:layout_gravity="center_horizontal" 
        android:layout_alignParentLeft="true" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:layout_marginTop="10dp" 
        android:layout_marginLeft="5dp" 
        android:layout_marginBottom="5dp" 
        android:src="@drawable/logo" 

        android:id="@+id/imageView2" /> 

       <LinearLayout 
        android:id="@+id/top_header" 
        android:layout_width="wrap_content" 
        android:layout_centerInParent="true" 
        android:layout_height="match_parent" 
        android:orientation="vertical" 
        > 
        <TextView 
         android:id="@+id/buy_finish_message" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         fontPath="@string/fontsIran" 
         android:textStyle="bold" 
         android:textSize="@dimen/text_size_between" 

         android:text="@string/buy_message" 
         android:textColor="@android:color/white" 
         android:textAlignment="center" 
         android:layout_marginTop="10dp" 
         /> 

        <TextView 
         android:id="@+id/mainpage_addAddress" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="@string/add_address" 
         fontPath="@string/fontsIran" 
         android:textAlignment="center" 
         android:textColor="@android:color/white" 
         android:textSize="@dimen/text_smallest_size" 
         android:layout_marginTop="-5dp" 
         android:layout_below="@+id/buy_finish_message" 
         /> 

       </LinearLayout> 

      </RelativeLayout> 


     </RelativeLayout> 
     <com.example.noavaran.drugstore.Helper.CustomViewPager 
      android:layout_weight="77" 
      android:id="@+id/viewPager" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_below="@+id/header_section" 
      fontPath="@string/fontsIran" 
      android:layout_above="@+id/tabs" 
      android:background="@android:color/white"/> 

     <android.support.design.widget.TabLayout 
      android:layout_weight="12" 
      android:id="@+id/tabs" 
      android:layout_gravity="right" 
      app:tabGravity="fill" 
      fontPath="@string/fontsIran" 
      app:tabTextAppearance="@drawable/selected_text" 
      android:layoutDirection="rtl" 
      app:tabIndicatorColor="@android:color/transparent" 
      app:tabBackground="@drawable/tabformat" 
      app:tabTextColor="@android:color/white" 
      app:tabSelectedTextColor="@color/color_tab_gray" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:background="@color/color_main" 
      > 

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

    </LinearLayout> 
    <android.support.design.widget.FloatingActionButton 
     android:layout_below="@+id/mainpage_addAddress" 
     android:maxHeight="100dp" 
     android:maxWidth="100dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/getaddress" 
     app:fabSize="mini" 
     android:scaleType="centerCrop" 
     android:id="@+id/fav_GetAddress" 
     android:onClick="fav_GetAddress" 
     app:backgroundTint="@color/color_main" 
     android:elevation="4dp" 
     app:borderWidth="0dp" 
     app:layout_anchorGravity="bottom|center" 
     app:layout_anchor="@+id/top_header" 
     /> 
</android.support.design.widget.CoordinatorLayout> 

enter image description here

+0

「weightSum」は完全にオプションです。ネストはパフォーマンスに影響します(ネガティブ) –

+0

@Rotwangしかし、なぜこの空のスペースが得られるのですか? – AndroidDev

+0

ビューに余分なマージンを追加した可能性があります。余白は余分なスペースを追加します。 –

答えて

-1

layout_weightはのLinearLayoutのプロパティです。 代わりに、ネストされたビューをLinearLayoutでラップし、それらにウェイトを適用します。

関連する問題