2016-12-22 1 views
0

ListView 및 을 포함하는이 XML 레이아웃을 가지고 있지만 CardView 내용이 때때로 화면 아래에 숨겨져 있기 때문에 전체 레이아웃에 스크롤을 적용하고 싶습니다.카드보기에서 안드로이드 스크롤

<?xml version="1.0" encoding="utf-8" ?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:card_view="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#ffffff" 
      android:orientation="vertical" 
      android:weightSum="2"> 

      <include 
       android:id="@id/tool" 
       layout="@layout/toolbar" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 

      <ListView 
       android:id="@+id/lvcontent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:layout_below="@+id/toolbar" 
       android:layout_marginLeft="20dp" 
       android:layout_marginRight="20dp" 
       android:layout_marginTop="50dp" /> 

      <android.support.v7.widget.CardView 
       android:id="@+id/cardView3" 
       android:layout_width="match_parent" 
       android:layout_height="160dp" 
       android:layout_below="@+id/lvcontent" 
       android:layout_margin="16dp" 
       android:layout_weight="0.2" 
       app:layout_anchorGravity="bottom" 
       card_view:cardCornerRadius="4dp" 
       card_view:contentPadding="8dp"> 

       <RelativeLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:id="@+id/tvcusttest" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_margin="5dp" 
         android:text="What Customers are Saying" 
         android:textColor="#000" 
         android:textSize="16dp" /> 

        <View 
         android:layout_width="match_parent" 
         android:layout_height="1dp" 
         android:layout_below="@+id/tvcusttest" 
         android:background="@android:color/darker_gray" 
         android:paddingLeft="3dp" 
         android:paddingRight="3dp" /> 
       </RelativeLayout> 

       <com.viewpagerindicator.CirclePageIndicator 
        android:id="@+id/cpiBanner" 
        android:layout_width="fill_parent" 
        android:layout_height="15dp" 
        android:layout_gravity="bottom|center_horizontal" 
        android:layout_marginBottom="7dp" 
        android:layout_marginTop="15dp" 
        android:padding="1dp" 
        app:fillColor="#ffffff" 
        app:pageColor="#80cccccc" /> 

       <android.support.v4.view.ViewPager 
        android:id="@+id/vpCustomerTestimonials" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" /> 

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

      <View 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_marginTop="30dp" 
       android:layout_weight="1"></View> 

      <LinearLayout 
       android:id="@+id/content" 
       android:layout_width="fill_parent" 
       android:layout_height="61dp" 
       android:layout_alignParentBottom="true" 
       android:layout_below="@+id/cardView3" 
       android:gravity="center_vertical" 
       android:orientation="horizontal" 
       android:weightSum="1"> 

       <Button 
        android:id="@+id/btnviewcart" 
        android:layout_width="fill_parent" 
        android:layout_height="match_parent" 
        android:layout_alignParentBottom="true" 
        android:layout_weight="0.5" 
        android:background="@color/selecteditem" 
        android:text="View Cart" 
        android:textAlignment="center" 
        android:textAllCaps="true" 
        android:textColor="#ffffff" 
        android:textSize="23sp" 
        android:textStyle="bold" /> 
      </LinearLayout> 
     </LinearLayout> 
</RelativeLayout> 

무엇이 잘못 되었나요? 화면 크기가 작 으면 절반 레이아웃이 화면 아래에 숨겨집니다. 난 그냥 스크롤 동작을 적용하는 것입니다. 나는 너에게 매우 감사 할 것이다.

+0

레이아웃을 스크롤보기에 배치하고 목록보기 대신 recyclerview를 사용하면 문제가 해결 될 수 있습니다. 만약 당신이 목록보기 자체를 사용하고 있다면 당신은 스크롤을 처리하고 스크롤 뷰를 별도로 처리해야한다. – Nivedh

+0

listview 자체를 사용해야하는데, 그에 따라 – neha

+0

을 추천한다. 선형 뷰 위에 scrollview를 놓으면리스트 뷰만 스크롤한다. 그리고 카드보기 contetn 여전히 화면 아래에 숨어 – neha

답변

0

목록보기를 사용 중이므로 바닥 글을 추가 할 수 있습니다. 다음이

View footerView = ((LayoutInflater) ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false); 
ListView.addFooterView(footerView); 

와 마찬가지로 바닥 글 레이아웃

 <?xml version="1.0" encoding="utf-8"?> 
     <android.support.v7.widget.CardView 
      android:id="@+id/cardView3" 
      android:layout_width="match_parent" 
      android:layout_height="160dp" 
      android:layout_below="@+id/lvcontent" 
      android:layout_margin="16dp" 
      android:layout_weight="0.2" 
      app:layout_anchorGravity="bottom" 
      card_view:cardCornerRadius="4dp" 
      card_view:contentPadding="8dp"> 


      <RelativeLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 

       <TextView 
        android:id="@+id/tvcusttest" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_margin="5dp" 
        android:text="What Customers are Saying" 
        android:textColor="#000" 
        android:textSize="16dp" /> 

       <View 
        android:layout_width="match_parent" 
        android:layout_height="1dp" 
        android:layout_below="@+id/tvcusttest" 
        android:background="@android:color/darker_gray" 
        android:paddingLeft="3dp" 
        android:paddingRight="3dp" /> 
      </RelativeLayout> 

      <com.viewpagerindicator.CirclePageIndicator 
       android:id="@+id/cpiBanner" 
       android:layout_width="fill_parent" 
       android:layout_height="15dp" 
       android:layout_gravity="bottom|center_horizontal" 
       android:layout_marginBottom="7dp" 
       android:layout_marginTop="15dp" 
       android:padding="1dp" 
       app:fillColor="#ffffff" 
       app:pageColor="#80cccccc" /> 

      <android.support.v4.view.ViewPager 
       android:id="@+id/vpCustomerTestimonials" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

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

그리고 활동 클래스는

public class MyListActivty extends ListActivity { 
    private Context context = null; 
    private ListView list = null; 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     list = (ListView)findViewById(android.R.id.list); 

     //code to set adapter to populate list 
     View footerView = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false); 
     list.addFooterView(footerView); 
    } 
} 

는 그럼에도 불구하고, 여전히 recyclerview를 사용하는 것이 될 것입니다.

+0

u는 두 개의 다른 xml을 listview에 만들어야하고 다른 하나는 cardview를 포함하는 바닥 글 레이아웃입니다. ???/그리고 나서 이것을 메인에 설정합니다. 활동 파일 – neha

+0

이 사실입니다. 꼬리말 디자인을위한 별도의 XML 파일을 갖게됩니다. – gilokimu

관련 문제