[英]Sliding fragment from bottom - up
我正在嘗試創建一個滑動面板,一旦收到推送通知,該面板便會顯示出來,但似乎無法正確顯示。
我希望面板本身是交互式的,所以我希望它是一個不同的片段。
我的主要活動xml如下所示:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/panel"
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content"></FrameLayout>
</FrameLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/gradientbg"
android:choiceMode="singleChoice"
android:divider="#1c1c1c"
android:dividerHeight="1dp" />
<!-- android:background="#111" -->
</android.support.v4.widget.DrawerLayout>
只是為了嘗試,我設置了這個簡單的片段並嘗試聽它的textView onClickListener:
public class Panel extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.panel, container, false);
view.bringToFront();
//view.animate().translationYBy(100f).setDuration(1300);
TextView text = (TextView) view.findViewById(R.id.textView);
text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
view.animate().translationYBy(-300f).setDuration(1300).start();
Toast.makeText(getActivity(), "fasf", Toast.LENGTH_SHORT).show();
}
});
return view;
}
}
不幸的是,textView沒有響應任何觸摸事件。 就像片段不在z-index的pof上一樣。
確保您在“活動XML”中引用了面板類,或者對id / panel進行了填充,以便您實際上在使用該類。
同樣,在解決此問題之后,請考慮使面板以抽屜式布局可以調用openDrawer / closeDrawer而不使用當前動畫的方式進行整合。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.