0

私は半透明の折りたたみツールバーを実装しようとしています。下の実線はツールバーと折り畳まれています。しかし、この行と画面の終わりとの間には、この奇妙なギャップ/スペースがあり、どこから来たのか分かりません。折りたたみツールバーと子LinearLayoutの間の余分なスペース

私はすでにapp:contentInsetStart="0dp"android:contentInsetStart="0dp"を挿入しようとしましたが、まだマージンを取り除いていません。

スクリーンショット:

Screenshot 1

Screenshot 2

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

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="300dp" 
    android:background="@android:color/transparent" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/ctbar_background" 
     app:contentScrim="@android:color/transparent" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     app:contentInsetStart="0dp" 
     android:contentInsetStart="0dp"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" 
      android:gravity="center" 
      android:orientation="vertical"> 

      <TextView 
       android:id="@+id/tvreqno" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="17049" 
       android:textColor="#ffffff" 
       android:textSize="75sp" /> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="50dp" 
        android:layout_height="50dp" 
        android:layout_marginRight="10dp" 
        android:src="@drawable/ic_pending" /> 

       <TextView 
        android:id="@+id/tvstatus" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:text="Assigned" 
        android:textColor="#ffffff" 
        android:textSize="35sp" /> 

      </LinearLayout> 

      <View 
       android:layout_width="40dp" 
       android:layout_height="1dp" 
       android:layout_marginBottom="50dp" 
       android:layout_marginTop="25dp" 
       android:background="#ffffff" /> 

     </LinearLayout> 


     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@android:color/transparent" 
      app:layout_collapseMode="pin" /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:layout_gravity="bottom" 
      android:background="#56dafe" 
      app:layout_collapseMode="pin" /> 

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

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

<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:paddingTop="10dp"> 

     <include layout="@layout/details_work_order2" /> 

    </LinearLayout> 


</android.support.v4.widget.NestedScrollView> 

My活動:

public class WorkOrderDetailsActivity extends MMSAppCompatActivity 
    implements AsyncResponseHelper { 

    private CollapsingToolbarLayout collapsingToolbarLayout = null; 
    private Toolbar toolbar = null; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.collapsing_toolbar); //if there is no valid saved instance for authentication, go to the log in page 
    data = getIntent().getExtras(); 
    cid = StringHelper.toStringSafe(String.valueOf(data.getInt("Cid"))); 
    thisView = findViewById(android.R.id.content); 
    status = StringHelper.toStringSafe(String.valueOf(data.getString("ExtraItemStatus"))); 
    statusEnum = StatusHelper.getStatusEnum(status); 
    activityHelper = new ActivityHelper(this, this, thisView, cid, 
     DataHolder.WorkOrderTableName, attachmentIsExternalTable, attachments, signatureNames); 
    thisActivity = this; 
    thisContext = this; 

    toolbar = (Toolbar) findViewById(R.id.toolbar); 
    thisActivity.setSupportActionBar(toolbar); 
    ActionBar actionBar = thisActivity.getSupportActionBar(); 
    actionBar.setDisplayHomeAsUpEnabled(true); 
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 
    collapsingToolbarLayout.setTitle("Work Order Detail"); 
    collapsingToolbarLayout.setExpandedTitleColor(Color.parseColor("#ffffff")); 
    collapsingToolbarLayout.setCollapsedTitleTextColor(Color.parseColor("#ffffff")); 
    collapsingToolbarLayout.setExpandedTitleGravity(Gravity.CENTER | Gravity.BOTTOM); 
    } 


    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
    int id = item.getItemId(); 

    if (id == android.R.id.home) { 
     onBackPressed(); return true; 
    } 

    return super.onOptionsItemSelected(item); 
    } 
} 
+0

http://tutorialsbuzz.com/2015/11/android-collapsingtoolbarlayout-example_7.html – GeekyInt

+0

あなたの「活動」のコードを投稿してください。 – earthw0rmjim

+0

@ earthw0rmjimは自分のアクティビティを追加しましたが、プレビューレンダリングからギャップを見ることができるので、アクティビティとは何の関係もないと思います。 – zenico

答えて

0

感謝の男私は問題を発見しましたが、それがなぜそうであるかはわかりません。私はCollapsingToolbarLayoutのバックグラウンドを子のLinearLayoutに移動しましたが、現在のギャップはなくなりました。

関連する問題