2016-08-30 5 views
0

하단 시트를 만들려고했는데 두 행이 포함되어 있습니다. 사용자가 앱을 열 때 첫 번째 행만 표시되도록하고 싶습니다. 에뮬레이터에서 앱을 실행하면 좋았지 만 실제 장치 (삼성 J7)에서 첫 번째 행과 두 번째 행의 일부가 실행되도록 시도했을 때 나타났습니다. 내 문제는 내 코드를 조정할 수있는 방법 때문에 단 1 행이 서로 다른 화면에 표시가 크기하단 시트를 다른 화면 크기로 크기를 조정하는 방법은 무엇입니까?

Emulator Image

Real device screenshot

내 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:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:padding="0dp"> 
    <fragment 
     xmlns:map="http://schemas.android.com/apk/res-auto" 

     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context="com.example.dell.drawroutes.MapsActivity" /> 

    <android.support.v4.widget.NestedScrollView 
     android:id="@+id/bottom_sheet" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_behavior="android.support.design.widget.BottomSheetBehavior" 
     android:background="@android:color/white" 
     android:clipToPadding="true"> 

     <GridLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:paddingTop="@dimen/card_margin" 
      android:columnCount="3"> 

      <android.support.v7.widget.CardView 
       android:id="@+id/distancecard" 
       android:layout_width="wrap_content" 
       android:layout_height="@dimen/Card_View_Height" 
       android:layout_margin="@dimen/card_margin" 
       android:layout_columnSpan="1" 
       android:layout_column="0" 
       android:layout_gravity="fill" 
       android:layout_row="0" 
       android:layout_columnWeight="1"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Info" 
         android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Hello World !" /> 

       </LinearLayout> 

      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView 
       android:layout_width="wrap_content" 
       android:layout_height="@dimen/Card_View_Height" 
       android:layout_marginBottom="@dimen/card_margin" 
       android:layout_marginLeft="@dimen/card_margin" 
       android:layout_marginRight="@dimen/card_margin" 
       android:layout_columnSpan="1" 
       android:layout_gravity="fill" 
       android:layout_column="1" 
       android:layout_row="0" 
       android:layout_columnWeight="1"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Friends" 
         android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Hello World !" /> 

       </LinearLayout> 

      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView 
       android:layout_width="wrap_content" 
       android:layout_height="@dimen/Card_View_Height" 
       android:layout_marginBottom="@dimen/card_margin" 
       android:layout_marginLeft="@dimen/card_margin" 
       android:layout_marginRight="@dimen/card_margin" 
       android:layout_columnSpan="1" 
       android:layout_column="2" 
       android:layout_gravity="fill" 
       android:layout_row="0" 
       android:layout_columnWeight="1"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Related" 
         android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Hello World !" /> 

       </LinearLayout> 

      </android.support.v7.widget.CardView> 
      <android.support.v7.widget.CardView 
       android:id="@+id/durationcard" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="@dimen/card_margin" 
       android:layout_marginLeft="@dimen/card_margin" 
       android:layout_marginRight="@dimen/card_margin" 
       android:layout_columnSpan="3" 
       android:layout_column="0" 
       android:layout_gravity="fill_horizontal" 
       android:layout_row="1"> 

       <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Duration" 
         android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="Hello World !" /> 

       </LinearLayout> 

      </android.support.v7.widget.CardView> 


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

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

자바 코드

,
+0

당신이 MapFragment가의 높이를 계산해야합니다 화면에 동적으로 기반 Java 코드의 크기. –

+0

어떻게 할 수 있습니까? 그리고 이것이 제가 어떻게 다른 화면 크기에 나타 내기 위해 단지 1 행을 얻는 데 도움이 될까요? –

+0

지도 높이 = 화면 높이 - 행 높이 1. 이렇게하면 처음에는 첫 번째 행만 표시됩니다. –

답변

0

귀하의 단일 카드 (레이아웃)에 따라 높이가 :

@dimen/Card_View_Height 

패스 setPeekHeight 기능이 값 :

bottomSheetBehavior.setPeekHeight(getContext().getResources().getDimension(R.dimen.Card_View_Height)); 
+0

감사합니다. D it worked –

관련 문제