Ответ 1
Настройте на Эми ответьте здесь, предполагая, что slideUpPanel блокирует onTouch для кнопок вкладки, тогда вы можете использовать eventlistener onTouch, чтобы запретить родительский макет, чтобы перехватывать любые события касания, такие как
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Creating The Toolbar and setting it as the Toolbar for the activity
toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
// Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of Tabs.
adapter = new ViewPagerAdapter(getSupportFragmentManager(),Titles,Numboftabs);
// Assigning ViewPager View and setting the adapter
pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(adapter);
// Assiging the Sliding Tab Layout View
tabs = (SlidingTabLayout) findViewById(R.id.tabs);
tabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width
// Setting Custom Color for the Scroll bar indicator of the Tab View
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
@Override
public int getIndicatorColor(int position) {
return getResources().getColor(R.color.tabsScrollColor);
}
});
// Setting the ViewPager For the SlidingTabsLayout
tabs.setViewPager(pager);
// THIS PART, ADD CODE HERE !
tabs.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
}
РЕДАКТИРОВАТЬ 1:
скользящая панель похожа на наложение поверх своих детей, поэтому, если вы сохраняете макет вкладки в дочерних элементах, скользящая панель будет отображаться прямо поверх вашей полосы вкладок, и эта скользящая панель остановит полосу табуляции, чтобы получить какие-либо щелчки или события касания, поэтому когда вы на самом деле пытаетесь прикоснуться или щелкнуть вкладки, на которые вы на самом деле не нажимаете/не нажимаете на вкладки, потому что вверх по ней находится скользящая панель. то, что вам нужно сделать, это поместить скользящий элемент за пределы макета планшета
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<!--this is outside sliding up panel layout-->
<com.example.www.slidinguppanelapp.SlidingTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f0f0f0"/>
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="@+id/sliding_layout"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoDragView="@+id/dragView"
sothree:umanoPanelHeight="68dp"
sothree:umanoShadowHeight="4dp">
<!-- MAIN CONTENT -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0000"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
</RelativeLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout
android:id="@+id/dragView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55eeeeee"
android:clickable="true"
android:focusable="false"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal">
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:textSize="14sp"/>
<Button
android:id="@+id/follow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical|right"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textSize="14sp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="fitStart"
android:src="@drawable/blur_bg">
</ImageView>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</LinearLayout>