0

콜 랩핑 도구 모음 레이아웃 내에 탭 레이아웃이있는보기 호출기가 있습니다. 각 탭에는 다른보기 호출기가 있습니다. 내 문제는보기 호출기의 내용을 스크롤 할 때입니다. 보기 호출기의 내용을 스크롤하려고 할 때 부모 축소 도구 모음 레이아웃이 스크롤됩니다. 내 활동의 레이아웃 탭의 요소에 사용되는 내 조각의뷰어 페이지 내용을 스크롤하는 방법

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:fitsSystemWindows="true" 
android:background="@color/colorBackground" 
android:id="@+id/layout_parent"> 
<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fitsSystemWindows="true" 
    android:theme="@style/MyTheme"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapse_toolbar" 
     android:layout_width="match_parent" 
     app:titleEnabled="false" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 
     <!--android:layout_height="520dp"--> 
     <LinearLayout 
      android:id="@+id/ll_parent" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:paddingTop="50dp" 
      android:orientation="vertical"> 
      <android.support.design.widget.TabLayout 
       android:id="@+id/tabs_upper" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:tabIndicatorColor="@android:color/white" 
       android:background="@color/colorPrimary" /> 
      <com.example.custom_view.custom_view_pager.MyWrapContentViewPager 
       android:id="@+id/pager_upper" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingTop="10dp" 
       android:scrollbars="vertical"/> 
      <!--android:layout_height="330dp"--> 
      <TextView 
       android:id="@+id/text_m" 
       android:layout_width="100dp" 
       android:layout_height="30dp" 
       android:text="More" 
       android:textColor="@color/color_red" 
       android:layout_marginTop="10dp" 
       android:layout_marginBottom="20dp" 
       android:layout_marginLeft="50dp"/> 
     </LinearLayout> 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar" /> 
     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:tabIndicatorColor="@android:color/white" 
      android:background="@drawable/tab_bar_bg" 
      android:layout_gravity="bottom"/> 

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

</android.support.design.widget.AppBarLayout> 
<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginLeft="@dimen/activity_horizontal_margin" 
    android:layout_marginRight="@dimen/activity_horizontal_margin" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

하나

public class TestFragment extends Fragment{ 

private ViewPager pagerSummary ; 
private ArrayList<String> slider_image_list; 

private TextViewPagerAdapter adapter; 


public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_whole_book_new, null); 
    setUpSlideView(root); 

    return root; 
} 


private void setUpSlideView(ViewGroup view){ 
    // method for initialisation 
    initSlider(view); 

} 

private void initSlider(ViewGroup view) { 
    pagerSummary = view.findViewById(R.id.pager_whole_book) 

    slider_image_list = new ArrayList<>(); 
    slider_image_list.add(getActivity().getResources().getString(R.string.law_one)); 
    slider_image_list.add(getActivity().getResources().getString(R.string.law_two); 

    adapter = new TextViewPagerAdapter(slider_image_list); 
    pagerSummary.setAdapter(adapter); 
    pagerSummary.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { 
     @Override 
     public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 
      //Toast.makeText(getActivity(), "wholebook onPageScrolled", Toast.LENGTH_SHORT).show(); 
     } 

     @Override 
     public void onPageSelected(int position) { 
      addBottomDots(position); 
      //Toast.makeText(getActivity(), "wholebook onPageSelected", Toast.LENGTH_SHORT).show(); 
     } 

     @Override 
     public void onPageScrollStateChanged(int state) { 
      //Toast.makeText(getActivity(), "wholebook onPageScrollStateChanged", Toast.LENGTH_SHORT).show(); 
     } 
    }); 


} 


public class TextViewPagerAdapter extends ObjectAtPositionPagerAdapter { 

    private final ArrayList<String> strings; 
    TextView textView1 ; 

    public TextViewPagerAdapter(ArrayList<String> strings) { 
     super(); 
     this.strings = strings; 
    } 

    @Override 
    public int getCount() { 
     return strings.size(); 
    } 

    @Override 
    public boolean isViewFromObject(View view, Object object) { 
     return view.equals(object); 
    } 

    @Override 
    public Object instantiateItemObject(ViewGroup container, int position) { 
     View view = View.inflate(container.getContext(), R.layout.test_item, null); 

     textView1 = view.findViewById(R.id.text_test); 
     textView1.setText(getActivity().getResources().getString(R.string.law_one)+ 
       getActivity().getResources().getString(R.string.law_one)+ 
       getActivity().getResources().getString(R.string.law_one)+ 
       getActivity().getResources().getString(R.string.law_one)+ 
       getActivity().getResources().getString(R.string.law_one)); 

     container.addView(view); 

     return view; 
    } 

    @Override 
    public void destroyItemObject(ViewGroup container, int position, Object object) { 
     container.removeView((View) object); 
    } 

    @Override 
    public CharSequence getPageTitle(int position) { 
     return "View" + position; 
    } 

} 

}

내 조각 레이아웃도

<LinearLayout 
     android:id="@+id/ll_pager" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 
     <com.example.custom_view.custom_view_pager.WrapContentViewPager 
      android:id="@+id/pager_whole_book" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

test_item.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/scroll" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:scrollbars="vertical"> 
<TextView 
android:id="@+id/text_test" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" /></ScrollView> 

답변

0

NestedScrollView을 살펴보십시오. 스크롤 할 내용을 간단하게 감싸십시오.

+0

링크가 죽을 수 있으므로 링크 전용 답변을 피하십시오. –

+0

Pete Carter, developer.android.com에 대한 링크이므로 링크가 작동하지 않을 가능성이 있습니다. –

+0

@ PragmaticDev 여기서 NestedScrollView를 사용합니까? 구체적으로 기재하십시오. – Zahidul