2016-08-05 3 views
5

부모 레이아웃에 android:fitsSystemWindows="true"이 포함되어 있으면 뷰 관련 작업이 발생할 때 내 BottomSheets 위치 지정을 방해한다는 것을 알게되었습니다. 안드로이드 : fitsSystemWindows와 개행을 방해하는 bottomSheets

구체적 I가 발생하고있어 하나의 텍스트 뷰 개행이 bottomsheets를 트리거 시스템/NOTIF 바의 높이에 의해 오프셋한다.

줄 바꿈 + fitsSystemWindows = 내가 버튼, 텍스트 뷰와 bottomsheet에 이르기까지 모든 관련이없는 물건을 제거 아래로 내 bottomsheet

밀 친다.

  • Button2를 : 마법 마자android:fitsSystemWindows="true"을 제거

를 발생, 모든 확인, 더 이상 이상한 행동 어디 setText("1\n2")입니다,하지만 난 시스템에 어떻게 fitsSystemWindows 색상의 효과를 잃을/notif-bar.

나는 또한 나의 bottomSheet이 android:fitsSystemWindows="false" 자신의 레이아웃 주려고 노력하지만 아무런 영향을 미치지 않았다.

어떻게 모두 fitsSystemWindows을 달성 할 수있다 = 사실 내 bottomSheets에이 이상한 오프셋 행동하지?

는 직접하세요! enter image description here

public class Test extends AppCompatActivity { 
    private BottomSheetBehavior bottomSheetBehavior; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.act_test); 

     LinearLayout bottomSheet = (LinearLayout) findViewById(R.id.root_btmsheet); 
     bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); 
     bottomSheet.post(new Runnable() { 
      @Override 
      public void run() { 
       bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); 
      } 
     }); 

     ((Button) findViewById(R.id.btn1)).setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       ((TextView) findViewById(R.id.info1)).setText("1"); 
      } 
     }); 
     ((Button) findViewById(R.id.btn2)).setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       // the culprit, Mr. Newline 
       ((TextView) findViewById(R.id.info1)).setText("1\n2"); 
      } 
     }); 
    } 
} 

act_test.xml

<?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" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" <-- the other culprit, Ms. Fits 
    tools:context=".Test"> 

    <!--<include layout="@layout/act_test_content" />--> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:orientation="vertical" 
     android:id="@+id/root_content"> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 
      <Button 
       android:id="@+id/btn1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="1" /> 
      <Button 
       android:id="@+id/btn2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="2" /> 
     </LinearLayout> 

     <TextView 
      android:id="@+id/info1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#e0e0e0" /> 

    </LinearLayout> 

    <!--<include layout="@layout/act_test_btmsheet" />--> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="200dp" 
     app:layout_behavior="@string/bottom_sheet_behavior" 
     android:orientation="vertical" 
     app:behavior_hideable="false" 
     app:behavior_peekHeight="50dp" 
     android:background="#5533b5e5" 
     android:id="@+id/root_btmsheet"> 

    </LinearLayout> 

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

에 대한 레이아웃 변경 후 정상적으로 작동하고, 문제는 이제 사라질 것으로 보인다. – TWL

+0

은 https://code.google.com/p/android/issues/detail에 23.3.0 https://developer.android.com/topic/libraries/support-library/revisions.html 링크에서 문제를 발견 ? id = 203057 – TWL

답변

0

내가 너무도 지원 라이브러리 25.1.0와 비슷한 문제가 있었다. 하지만 나중에 CollapsingToolbarLayout을 사용하지 않았기 때문일 수 있다고 생각했습니다. 나는 그것을 포함 쾅! .. 그것도 최신 지원 라이브러리 25.x.x와이 재 방문으로 인해 바꿈