2016-08-05 18 views
5

ile çakışan yeni satır Üst düzende android:fitsSystemWindows="true" içeriyorsa, görünümle ilgili bir eylem gerçekleştiğinde BottomSheets konumlandırmamla etkileşime gireceğini öğrendim. Android: fSystemWindows ve bottomSheets

Özellikle ben karşılaşmak ediyorum tek: Bir textview bir satır bottomsheets tetikleyecek sistemi/bildirm-bar yüksekliğine göre dengelemek için.

satır + fitsSystemWindows = I düğmeler, textview ve bottomsheet aşağı bütün alakasız şeyler ortadan aşağı benim bottomsheet

shoves.

  • BUTTON2: sihirli En kısa zamandaandroid:fitsSystemWindows="true" kaldırmak olarak

olur, hepsi tamam, artık tuhaf davranışlar nerede setText("1\n2"), ama sistemde nasıl fitsSystemWindows renklerin etkisini kaybedecek/notif bar.

Ben de bottomSheet android:fitsSystemWindows="false" kendi düzeni vermeye çalıştım ama herhangi bir etkisi olmuştur.

nasıl hem fitsSystemWindows elde edebilirsiniz = true benim bottomSheets bu garip ofset davranış olmadan?

kendiniz görün! 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

herhangi düzen değişikliklerden sonra normal çalıştığı, sorun şimdi gitmiş gibi görünüyor. – TWL

+0

sadece https://code.google.com/p/android/issues/detail için 23.3.0 https://developer.android.com/topic/libraries/support-library/revisions.html bağlantılarda sorunu aşağı bulundu ? id = 203057 – TWL

cevap

0

ben de bile destek kütüphanesinde 25.1.0 ile benzer bir sorun vardı. Ama daha sonra bir CollapsingToolbarLayout kullanmadığı için olabileceğini anladım. Onu dahil ve bam! .. hatta en son destek kütüphaneleri 25.x.x ile bu Revisited nedeniyle linebreaks